Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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')");
    ?>

  • #2
    New Coder
    Join Date
    Sep 2007
    Location
    Hanoi, Vietnam
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •