Monthly Archives

April 2013

So you found yourself looking for one of the following keywords ‘PHP SOAP Repeated Element Name‘ or ‘SOAP Structure Repeated Name‘.

Then look no further, I’m going to show you how to properly address this problem.
PHP SoapClient is not the most complete library out there, it’s actually rather poor at times, if you have the time to test and implement, a better, faster, more complete library to replace PHP SoapClient, then google this: WSO2 Web Services Framework for PHP (WSO2 WSF/PHP), it’s a paid-turned-open source project.

In reference to our problem, you may have a structure like this:

And whether you are building the response using Objects or Arrays, the answer is pretty much the same.

In case you are working with a complex WSDL Specification you are probably using Objects, for perfect control over the namespaces.

The Solution
The simplest solution relies on a pretty little thing called, ArrayObject, implemented in PHP 5, which can be used whether you are building an Array or an Object.

If you are a building simple response without need for namespace declarations, you can just put the value instead of using SoapVar’s.

The example above will output the XML repeated element example above when sent via SOAP.

Read more →

PHP snippet to Watermark Images Automatically.

This snippet brings a one line .htaccess, if you choose to use it, any call to a image on your website, gets automatically watermarked, stopping anyone from downloading the image without the watermark.

You can also center the watermark in the following ‘variable name‘ positions:


You can either change the default settings in the .php file, or if you invoke the script direct directly you can pass parameters either in .htaccess or in a html page, as you can see in the demo.

The scripts uses two merging type functions (imagecopy and imagecopymerge).
In case you already have a .PNG or .GIF with the opacity set, you can set the script to just overlay it, otherwise if you use a JPEG or any other file without transparency set, you can choose the opacity and the script will merge it accordingly.

You can find the code over at github. You can find a Demo here.