View Full Version : problem with array storage in database

07-16-2008, 12:49 PM

i write a code code to capture all the image urls in the website we we submit the url of the website.And stored all the urls in the database.Now my requirement is to how to get the individual elements of the array.In the below code i print matches[0] it gives first element in the array.(ex : when i give the url as http://www.yahoo.com and it capture the url as http://www.yahoo.com/images/image.jpg and the result of matches gives all images urls ,matches[0] gives as 'h 'and matches[1] is 't'.But my requirement is to get the perticular total url that means http://www.yahoo.com/images/image.jpg ).For that purose how i write a changes in my code to get perticular url.plz tell that.

echo "<b>Capture Images URLS :</b><br><br>";
preg_match_all( "/<img(.*)src=(\"|')(.*)(\"|\')(.*)[\/]?>/siU", $content, $match, PREG_PATTERN_ORDER);
$matches=implode("|", $match[3]);
mysql_query("insert into imageurls(urlname) values ('$matches')");

07-17-2008, 10:55 AM
preg_math_all returns an array of result found (in string).
$match[3] is only a string, you can't implode it into array.
You can implode the result after use preg_match_all ($match)

Use $matches=implode("|", $match) instead.