dreamwest Posted March 16, 2012 Share Posted March 16, 2012 Simple array_replace() but it throwing an error, can anyone see what ive done wrong? while($row2 = mysql_fetch_assoc( $res2 )){ $title2 = "replace desc"; //$row2 prints array( l_desc => title ) $row2 = array_replace($row2, array('l_desc' => $title2)); print_r($row2); $show[] = $row2; }//end while Fatal error: Call to undefined function array_replace() in ..... Im using PHP 5+ Quote Link to comment https://forums.phpfreaks.com/topic/259035-array_replace/ Share on other sites More sharing options...
requinix Posted March 16, 2012 Share Posted March 16, 2012 ...but not PHP 5.3 apparently. Check the manual page. Quote Link to comment https://forums.phpfreaks.com/topic/259035-array_replace/#findComment-1327953 Share on other sites More sharing options...
dreamwest Posted March 16, 2012 Author Share Posted March 16, 2012 yay ... Quote Link to comment https://forums.phpfreaks.com/topic/259035-array_replace/#findComment-1327959 Share on other sites More sharing options...
kicken Posted March 16, 2012 Share Posted March 16, 2012 If your using strings for the keys and not numbers, which I assume you are since your using mysql_fetch_assoc, then array_merge should accomplish the same thing as array_replace. I assume you have more than just that one column to replace? If not you'd probably be ahead to just do $row2['l_desc']=$title2; Quote Link to comment https://forums.phpfreaks.com/topic/259035-array_replace/#findComment-1327968 Share on other sites More sharing options...
dreamwest Posted March 16, 2012 Author Share Posted March 16, 2012 Yep already did it, just added the extra key and merged it with the original array Quote Link to comment https://forums.phpfreaks.com/topic/259035-array_replace/#findComment-1327980 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.