Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-16-2008, 12:49 PM   PM User | #1
swethak
New Coder

 
Join Date: Jul 2008
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
swethak is an unknown quantity at this point
problem with array storage in database

hi,

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.

PHP Code:
<?
echo "<b>Capture Images URLS :</b><br><br>";
preg_match_all"/<img(.*)src=(\"|')(.*)(\"|\')(.*)[\/]?>/siU"$content$matchPREG_PATTERN_ORDER);
print_r($match[3]);
$matches=implode("|"$match[3]);
mysql_query("insert into imageurls(urlname) values ('$matches')");
?>
swethak is offline   Reply With Quote
Old 07-17-2008, 10:55 AM   PM User | #2
Nothinglastz
New Coder

 
Join Date: Sep 2007
Location: Hanoi, Vietnam
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Nothinglastz is an unknown quantity at this point
hi,
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.
Nothinglastz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:53 PM.


Advertisement
Log in to turn off these ads.