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
    Nov 2006
    Location
    INDIA
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    find a html tag in string

    Hi

    PHP Code:
    $string=' this is image 1 <img src="www.abc.com/abc.gif"'> and second is <img src="www.df.com/edfg.jpg">;
    function 
    getAttribs($t$a$s) {
            
    preg_match_all("/(<".$t." .*?".$a.".*?=.*?\")(.*?)(\".*?>)/"$s$m);
            return 
    $m[2];
    }
    $arr=getAttribs('img''src'$string); 
    Here i get all the src of <img> tag.
    Now i want to replace the src part with something else.
    How can i achieve this.


    thanks in advance.
    Last edited by shaileshpatil; 11-26-2007 at 09:37 AM. Reason: found solution but still...
    -------------------------
    Shailesh Patil
    -------------------------

  • #2
    New Coder
    Join Date
    Nov 2006
    Location
    INDIA
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The output of the above function was array.
    I looped through foreach and used str_replace() function.

    Thanks
    -------------------------
    Shailesh Patil
    -------------------------


  •  

    Posting Permissions

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