回显数组值

I have a Joomla widget to make and I made a php script that gets the latest articles. The images of all articles are inside the introtext value in this way: bla bla bla bla bla

I have made the following code to get the images src value:

    $variable = $row['introtext'];
    preg_match_all('/(src)=[^ ]+(\.gif|\.jpg|\.jpeg|\.png)/',$variable, $out);
    print_r($out[0]);
    echo "http://mysiteurl.com/".$out[0]." ";

What I get printed when I hit the file is:

Array ( [0] => src="images/DECEMBER2014/ello-vs-facebook.jpg ) http://mysiteurl.com/Array

Should not $out[0] echo this: src="images/DECEMBER2014/ello-vs-facebook.jpg

Any help?

Try this:

$variable = $row['introtext'];
preg_match_all('/(src)=[^ ]+(\.gif|\.jpg|\.jpeg|\.png)/',$variable, $out);
print_r($out[0][0]);
echo "http://mysiteurl.com/".$out[0][0]." ";

Read more about preg_match_all here

Are you looking for this...

foreach($variable as $key=>$value)
{

}