Skip to content

Setup a whole range of PHP if statements for code to pull from

I have a whole bunch of values, that need to correspond to some other values. I’ve so far setup an array as per the below: I also have a variable, $input that provides a number value. I need to figure out a way to say something like: My array list will end up having hundreds of values in it, so

PHP – get URL param with or without key

I know how to do this in a clunky verbose way, but is there an elegant way to retrieve a single param from a URL whether or not there is a key or index page in the URL? i.e. there will never be a &secondparam=blah. $_GET[“slug”] only works if the url has slug=foobar E.g. return foobar for any …

json encode specific object’s property

I have an array: I want to return a json_encode for this array, but only for “key2” and “key3” attributes. For the moment that: But this is not okay as the array may also contain other properties. If it is possible, I prefer not to use loops… (sorry for my english) Answer This so…

PHP DirectoryIterator with natsort

I am retrieving a list if photo files from a directory and echoing into a web page so that the page can be created automatically for any photo album. The following is working fine, but the result is that the photos are not in natural order which is what I’d prefer: ?> Answer The sort category of func…

Problem with PHPMailer attaching file (only attaches after page refresh)

I have a script that generates a Certificate upon form submit, as well as sends the generated certificate to the recipients email address. When i enter the details into the HTML form, and submit the form, it fails and comes up with an error saying PHPMailer unable to access the file. But when i click on REFRE…

Apache2 does not show .png images

I just started migrating my code to the google cloud. The server runs Ubuntu but does not display my images (.png). When I open the console and open the link address directly I receive a 404 not found; but when I just go to `http://example.com/icons“I receive a 403 Forbidden message. Could it be the cas…