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 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    search and assign

    hi

    im storing textarea values to img field of database and one row looks like

    PHP Code:
    [IMG]http://www.abc.com/albums/bb449/abc/abc/3.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/4.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/6.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/5.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/2.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/cover.jpg[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/1.png[/IMG] 
    is it possible to search for "cover" and assign entire line to one variable?

    like
    PHP Code:
    [IMG]http://www.abc.com/albums/bb449/abc/abc/cover.jpg[/IMG]<br /> 
    line to one variable and others to another variable?

    also is it possible to sort variable according to number? so final will be like

    PHP Code:
    [IMG]http://www.abc.com/albums/bb449/abc/abc/cover.jpg[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/1.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/2.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/3.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/4.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/5.png[/IMG]<br />
    [IMG]http://www.abc.com/albums/bb449/abc/abc/6.png[/IMG]<br /> 

    Any help would be great. sorry for the language errors, hope someone can understand what i mean


    Regards.

  • #2
    New Coder
    Join Date
    Nov 2010
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    preg_match() matches the value "cover" but i couldn't find a way to select all line which contain "cover" and assign that to a variable.

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I would assign each line to an array element and then search each element separately (with a loop). When you find a match, you can re-assign the array element, or just use it for whatever you need right then and there.

    Use explode() using a delimiter of "newline" (\n) to get the thing into an array.

  • #5
    New Coder
    Join Date
    Jun 2010
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    I would assign each line to an array element and then search each element separately (with a loop). When you find a match, you can re-assign the array element, or just use it for whatever you need right then and there.

    Use explode() using a delimiter of "newline" (\n) to get the thing into an array.
    Thanks a lot for the idea, got it work with your idea


  •  

    Posting Permissions

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