satishgaudo.com

Understanding technology

Posts Tagged 'array_walk function in class'

How to use array_walk function in class

In the example below dbop is an test class: class dbop { $aUpdateData=Array(); public function createOnDupUpdateString($val,$key){ $this->aUpdateData[$key]=$val; } public function insertOrUpdOndupKey($aUpdate) { array_walk($aUpdate, array($this, ‘createOnDupUpdateString’)); // create new array. } } In the function “insertOrUpdOndupKey” for each element of array update function “createOnDupUpdateString” is applied using “array_walk”. For the function array_walk, pass the source array ($aUpdate) as first parameter and pass array of class object “$this” and name [...]

24 March 2010 at 15:53 - Comments