Tag Archives: array

Send array values from PhP form to JavaScript

Description: Having a PhP form, we need to manipulate in JavaScript an object that depends on the form input. Solution: The best way to do it is to use an encoded JSON object or an AJAX call. The AJAX call … Continue reading

Posted in Script | Tagged , , , , | 2 Comments

Convert StdClass objects to SOAP compliant objects

Description: Having an obtained StdClass Object, we require to change it into a SOAP structure object or Array compliant. Solution: Converting a StdClass Object with PhP basically means iterating the object and populating the public properties with elements from the … Continue reading

Posted in Best practices, PhP | Tagged , , , , | Leave a comment

Iterate Array contents in Smarty templates

Description: Iterate an Array passed as a variable in a Smarty template Solution: The equivalent of foreach() clause in PHP translates as section in Smarty templates, as following: {section name=arrayID loop=$theArray}     <input type=checkbox” name=”{$theArray[arrayID ]}” {/section} The code above … Continue reading

Posted in PhP | Tagged , | Leave a comment

Save an array into database table

Description: How to save an Array variable as a regular database value? Solution: PHP offers the serialize() function, that creates a representation of the variable that can be stored everywhere. This can be used for other types of variables as … Continue reading

Posted in PhP, SQL | Tagged , , | Leave a comment