Skip to content

Get category tree recursively (Yii)

I have a table with following structure: categories id name parent_id I want to get the tree of categories with single function. I’ve written something like this in my model, but it doesn’t work. Can someone help me with this? Thanks. Answer I’ve finally solved the issue. If someone interest…

How can I get parameters from a URL string?

I have an HTML form field $_POST[“url”], having some URL strings as the value. Example values are: https://example.com/test/1234?email=xyz@test.com https://example.com/test/1234?basic=2&email=xyz2@test.com https://example.com/test/1234?email=xyz3@test.com https://example.com/test/1234?email=xy…

Find and replace emails and phone numbers in PHP

I was hoping for a little help on this, as it’s confusing me a little… I run a website that allows users to send messages back and forth, but on the inbox i need to hide both emails and phone numbers. Example: This is how a sample email would look like. Hi, my phone is +44 5555555 and email is

Send multiple elements with jQuery POST

I have this jQuery code to add elements in a table row with an “add” button: $(“#add”).click(function() { $(‘#selected > tbody:last’).append(‘

<select id='…

Add ‘x’ number of hours to date

I currently have php returning the current date/time like so: What I’d like to do is have a new variable $new_time equal $now + $hours, where $hours is a number of hours ranging from 24 to 800. Any suggestions? Answer You may use something like the strtotime() function to add something to the current ti…