jamesxg1 Posted June 3, 2010 Share Posted June 3, 2010 Hiya peeps, I have this Array ( [0] => Array ( [0] => { if value>valuetwo } [1] => { do } ) [1] => Array ( [0] => if value>valuetwo [1] => do ) ) But this could be different every time as I am using preg_match_all() how would I make them merge together or at least unset the values in curly brackets? Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/203794-how-do-i-merge-a-mulit-dimensional-array/ Share on other sites More sharing options...
dabaR Posted June 3, 2010 Share Posted June 3, 2010 If I understand, you want to go through all the values inside brackets, right? Quote Link to comment https://forums.phpfreaks.com/topic/203794-how-do-i-merge-a-mulit-dimensional-array/#findComment-1067362 Share on other sites More sharing options...
jamesxg1 Posted June 3, 2010 Author Share Posted June 3, 2010 Yes, what I am hoping to do is unset all the values in curly brackets ( { } ) ans then put the rest in one array. Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/203794-how-do-i-merge-a-mulit-dimensional-array/#findComment-1067365 Share on other sites More sharing options...
dabaR Posted June 3, 2010 Share Posted June 3, 2010 if this Array ( [0] => Array ( [0] => { if value>valuetwo } [1] => { do } ) [1] => Array ( [0] => if value>valuetwo [1] => do ) ) is an array called $matches, I think what you are looking for is already in $matches[1]. Quote Link to comment https://forums.phpfreaks.com/topic/203794-how-do-i-merge-a-mulit-dimensional-array/#findComment-1067371 Share on other sites More sharing options...
jamesxg1 Posted June 3, 2010 Author Share Posted June 3, 2010 if this Array ( [0] => Array ( [0] => { if value>valuetwo } [1] => { do } ) [1] => Array ( [0] => if value>valuetwo [1] => do ) ) is an array called $matches, I think what you are looking for is already in $matches[1]. Agreed, and when I do this. foreach($match[1] as $k => $v) { $data[] $v; } I loose most of the information. Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/203794-how-do-i-merge-a-mulit-dimensional-array/#findComment-1067372 Share on other sites More sharing options...
dabaR Posted June 3, 2010 Share Posted June 3, 2010 To me $data = $matches[1];[code=php:0] seems like a better way to express what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/203794-how-do-i-merge-a-mulit-dimensional-array/#findComment-1067374 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.