mac_gabe Posted November 21, 2010 Share Posted November 21, 2010 Hi, I'm trying to explode an array into a multidimensional array using <br /> tags as splitters but just can't get the syntax right! I can do lines of the array one by one, but not the whole lot at once. I'd really appreciate a quick example of an explode inside an array. $myarray looks something like this with print_r: ( [0] => [1] => some_html<br />some_html<br />some_html<br /> [2] => some_html<br />some_html<br />some_html<br /> [3] => some_html<br />some_html<br />some_html<br /> ) and I want to turn it into this: ( [0] => [1] => [0]some_html [1]some_html [2]some_html [2] => [0]some_html [1]some_html [2]some_html [3] => [0]some_html [1]some_html [2]some_html ) I've tried this $myarray = explode ("<br />", $myarray); but it doesn't work … It doesn't matter too much if there's are a few empty lines in the array from the final <br /> tags. Many thanks, as ever, for any help. Quote Link to comment Share on other sites More sharing options...
mac_gabe Posted November 21, 2010 Author Share Posted November 21, 2010 OK I've done it with a for loop $original_array_count= count($original_array); for ($u=1; $u < $original_array_count; $u++) { $new_array[$u] = explode('<br />', $original_array[$u]); } print_r ($new_array); I thought maybe there was a simpler way of doing it but I guess this works fine. 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.