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: Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.