I have the following regex:
$regex = '/https?\:\/\/[^(\"|\\\) ]+/i';
for ($i = 0; $i < count($column7); ++$i)
{
preg_match_all($regex, $column7[$i], $matches[$i]);
print_r($matches[$i]);
}
Column 7 is an array made up of many different strings. I want to match all the urls and store them in a single array $matches such that I have all the matches from each element in a single array like the example below.
Array
(
[0] => https://domain.comf3aeaf
[1] => https://ureasdjlkfjasldkf.com
[2] => http://heelooo.com
[3] => https://www.asdfasdfasd.com
[4] => https://asdfafrgasrgas.com
[5] => http://rgtfgsdagf.com
[6] => http://asfgdfhgasdgafsd.com
[7] => http://asdghdthgaterge.com
[8] => https://asdgsdhdsthaerararrrr.com
[9] => https://t.com
[10] => http://abc.cmo
)
When I print_r($matches[$i]) it looks like I get a multidimensional array which just overwrites itself. How can I just get a one dimensional array with all the urls one after the other?
I hope that makes sense!
Actual Output I'm getting:
Array
(
[0] => Array
(
[0] => https://domain.comf3aeaf
[1] => https://ureasdjlkfjasldkf.com
[2] => http://heelooo.com
)
)
Array
(
[0] => Array
(
[0] => https://www.asdfasdfasd.com
[1] => https://asdfafrgasrgas.com
[2] => http://rgtfgsdagf.com
[3] => http://asfgdfhgasdgafsd.com
[4] => http://asdghdthgaterge.com
)
)
Array
(
[0] => Array
(
[0] => https://asdgsdhdsthaerararrrr.com
[1] => https://t.com
[2] => http://abc.cmo
)
)