eits Posted July 24, 2009 Share Posted July 24, 2009 Hi, I'm using preg_match_all to create an array. (Each time an instance of text appears on a webpage it adds it to the array). I think what I'm ending up with is a double dimensional array. If I print_r I get this before the data I want (if I have ten items in the array, there will be 10 blanks: Array ( [0] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [1] => Array ( [0] => Can anybody please tell me how I can remove these from my array? Quote Link to comment https://forums.phpfreaks.com/topic/167309-i-expect-this-is-a-very-simple-array-problem/ Share on other sites More sharing options...
wildteen88 Posted July 24, 2009 Share Posted July 24, 2009 How are you constructing the array? Post your code Quote Link to comment https://forums.phpfreaks.com/topic/167309-i-expect-this-is-a-very-simple-array-problem/#findComment-882186 Share on other sites More sharing options...
eits Posted July 24, 2009 Author Share Posted July 24, 2009 hi i'm using this function function getOptionValues($string, $first, $second) { $pattern = "/<$first(.*?)$second/"; preg_match_all($pattern, $string, $matches); print_r($matches); } Quote Link to comment https://forums.phpfreaks.com/topic/167309-i-expect-this-is-a-very-simple-array-problem/#findComment-882187 Share on other sites More sharing options...
vineld Posted July 24, 2009 Share Posted July 24, 2009 preg_match_all will always return this two-dimensional array. Why do you need to remove the first one at all? Why not simply NOT use it? array_shift might do the trick. Quote Link to comment https://forums.phpfreaks.com/topic/167309-i-expect-this-is-a-very-simple-array-problem/#findComment-882193 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.