Just for fun, I'm trying to code something that will scan a website for YouTube URLs and save them. The URLs will not be within tags so I need to use regex. I have that part down. But how I do go about echoing the URLs from an array?
What I have so far:
<?php
$website = file_get_contents('http://boards.4chan.org/mu/res/41283979');
$reg_exURL = "/(?:https?://)?(?:www\.)?youtu(?:be\.com/watch\?(?:.*?&(?:amp;)?)?v=|\.be/)([\w\-]+)(?:&(?:amp;)?[\w\?=]*)?/";
if(preg_match($reg_exURL, $website, $urls)) {
// Echo all values in the array
foreach ($urls as $url) {
echo $url;
}
} else {
echo "No URLs Found.";
}
?>
But when I echo $url, I just get the word "Array". I want to see all the URLs, preferably one on each line.