So I have been searching for a while and cannot find the answer to a simple question. Is it possible to have an array of objects in PHP? Such as: For some reason I have not been able to find the answer anywhere. I assume it is possible but I just need to make sure. Answer The best place to
Properly parse a Mongo cursor to PHP
When converting a MongoCursor to PHP I use this script. Which was presented here StackOverflowSO using the upper method, the structure is same but _id is whereas using the lower script which yields the below included result. Unfortunately, this results in the actual object being embedded into an array with th…
Explode a string on upper case characters?
Ho can i explode $param string into $chunks pieces based on upper-case characters? $string = ‘setIfUnmodifiedSince’; $method = substr($string, 0, 3); $param = substr($string, 3); // Split $param …
selecting unique values from a column
I have a MySQL table which contains the following type of information: Here is an example of a script I use to get data from this table: This script displays every date from the table, e.g. I would like to only display unique dates, e.g. Answer Use the DISTINCT operator in MySQL:
Regular expression matching for entire string
I’m very new to PHP. I need to check whether a given string has characters from a given set, say {a, b, c}. So, I am trying regular expressions. “(abc)+” should do the trick. However, looking at the manual entries for preg_match and associated functions, I noticed that these functions perfor…
Convert number of minutes into hours & minutes using PHP
I have a variable called $final_time_saving which is just a number of minutes, 250 for example. How can I convert that number of minutes into hours and minutes using PHP in this format: 4 hours 10 …
Adding 1 hour to time variable
I have a time to which I want to add an hour: I’ve tried: But none of the above work. Answer Worked for me.. Explanation: strtotime(’10:09′) creates a numerical timestamp in seconds, something like 1510450372. Simply add or remove the amount of seconds you need and use date() to convert it b…
Getting first / last date of the week
Is it possible to get the first / last date of a week using PHP’s Relative Date Time format? I’ve tried to do: As you can see it doesn’t output the correct dates. According to the docs this should be possible if I’m correct. Am I doing something terrible wrong? EDIT I need to use PHP&#…
Add different class to even and odd divs
I have a block of PHP code that looks like this: $flag = false; if (empty($links)) { echo ‘
You have no uploaded images
‘; } foreach ($links as $link) { $…
Import RSS feed from LinkedIn?
Is there any way of getting the RSS feed of a LinkedIn group (like this: http://www.linkedin.com/groups/Behance-Creatives-55523) to show on a webpage? I would like to display the most recent discussion on a page. Answer There is no RSS feed for LinkedIn groups, as they all require the viewer to be a LinkedIn …