php

PHP Portable Paths

Frankly, I don’t care about people wanting to run my code on a Windows box and it not working. But in reality, for some reason, there are people who write code using computers running the Microsoft Windows operating system. Why don’t they use a Mac, or if they don’t have or want to spend the PHP Portable Paths

PHP Get the First of Next Month

While having fun with dates, I needed to get the timestamp for the first of the next month, here’s how I did it with PHP. strtotime(date(‘m’, strtotime(‘+1 month’)) . ‘/01/’ . date(‘Y’, strtotime(‘+1 month’))); I then used that to create a PHP DateTime object like this. $date = new DateTime(); $date->setTimestamp(strtotime(date(‘m’, strtotime(‘+1 month’)) . ‘/01/’ PHP Get the First of Next Month

PHP SoapClient Create An Array of Objects

In PHP, you can’t create an array with the same key more than once. You can’t do this. $array[‘transaction’] = “success”; $array[‘transaction’] = “fail”; Obviously, you can DO that, but “fail” will overwrite “success.” But when making Soap calls, it’s often necessary to pass in a structure like this. <users> <user> <firstname>Jamal</firstname> </user> <user> <firstname>Acacia</firstname> PHP SoapClient Create An Array of Objects