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+ 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. 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 ... 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; 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 Link to comment https://forums.phpfreaks.com/topic/259035-array_replace/#findComment-1327980 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.