Skip to content

Tag: php

Array of PHP Objects

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…

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…

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&#…

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 …

getimagesize and https

I am retrieving facebook album images from facebook.I have calculating the image size using the php function getimagesize.This function is working fine when the url is in http mode.When the facebook return the image url with https the getimagesize giving error.How i can calculate the imagesize of images with …

Redefining constants in PHP

Is it possible to redefine a constant in php which was defined by the define function? I have a class with several constants that contains the user data. I’m trying to use the class for more than one user. I did not write this class, but I am using it due to time constraints. I do not know why the