nmohamm Posted May 18, 2010 Share Posted May 18, 2010 Can anyone help me with the following question please?? create a function to replace all instances of 'test' with 'frog' within the values of the following array $test = array('key1'=>'test1', 'key2'=>'value2', 'key3'=>array('test','test1','test2')); Answer: Link to comment https://forums.phpfreaks.com/topic/202209-php-array-question-help/ Share on other sites More sharing options...
teamatomic Posted May 19, 2010 Share Posted May 19, 2010 loop through the array. Test the value against is_array. If its an array loop again. if the value is not an array test to see if its ''test' if it is replace the value with what you want. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/202209-php-array-question-help/#findComment-1060323 Share on other sites More sharing options...
JAY6390 Posted May 19, 2010 Share Posted May 19, 2010 You should look up "recursive functions" to understand what teamatomic has described Link to comment https://forums.phpfreaks.com/topic/202209-php-array-question-help/#findComment-1060325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.