moon 111 Posted March 29, 2008 Share Posted March 29, 2008 I have a multidimensional array. It is organized like so: $file = array(array("title1", "message1"), array("title2", "message2")); etc... I'm trying to move the "title" part and the "message" part into two different arrays so that I have $title = array("title1", "title2"); $message = array("message1", "message2"); Would this work? foreach($file as $value) { $title[] = $value[0]; $message[] = $value[1]; } Link to comment https://forums.phpfreaks.com/topic/98508-multidimensional-foreach/ Share on other sites More sharing options...
wildteen88 Posted March 29, 2008 Share Posted March 29, 2008 Yes that should work fine. To see if the the $title and $message arrays are populated properly place the following code after the foreach echo '$title <pre>' . print_r($title, true) . '</pre>'; echo '$message <pre>' . print_r($message , true) . '</pre>'; Link to comment https://forums.phpfreaks.com/topic/98508-multidimensional-foreach/#findComment-504113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.