jaymc Posted April 20, 2008 Share Posted April 20, 2008 just a quick one, I cant remember how to do this I want to execute a function on every element in an array, but leave the result in the array So instead of this $song_data[song_name] = mysql_real_escape_string($song_data[song_name]); $song_data[artist_name] = mysql_real_escape_string($song_data[artist_name]); $song_data[album_name] = mysql_real_escape_string($song_data[album_name]); $song_data[genre] = mysql_real_escape_string($song_data[genre]); $song_data[year] = mysql_real_escape_string($song_data[year]); $song_data[kbps] = mysql_real_escape_string($song_data[kbps]); I could have something like magic_function($song_data, mysql_real_escape_string()); Thanks! Link to comment https://forums.phpfreaks.com/topic/102045-solved-apply-function-to-all-array/ Share on other sites More sharing options...
dptr1988 Posted April 20, 2008 Share Posted April 20, 2008 array_walk() http://us2.php.net/manual/en/function.array-walk.php Link to comment https://forums.phpfreaks.com/topic/102045-solved-apply-function-to-all-array/#findComment-522244 Share on other sites More sharing options...
jaymc Posted April 20, 2008 Author Share Posted April 20, 2008 Great Link to comment https://forums.phpfreaks.com/topic/102045-solved-apply-function-to-all-array/#findComment-522275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.