www.webdeveloper.com
Results 1 to 3 of 3

Thread: Multiple data retrive

  1. #1
    Join Date
    Oct 2006
    Posts
    6

    Multiple data retrive

    hi,
    i am new coder in PHP world.
    Help me about this problem.

    ###problem1#################

    i want to retrive data from some text.

    lasejfsdjfsdf<abc>i want retrive it<efg>sfuhsdfk<abc>again i retrive it<efg>lsdfjosdjf<abc>again & again i retrive it<efg>ksdfjhnsidufh

    i want to retrive data from middle of <abc> & <efg>

    ###problem1 end#################

    ###problem2#################

    sdnfidvhuiweweonvoiwejhfsdmnvlknweialksfdmiosafjalwfn vihnwieon v

    from this line i want to change all v to as v1, v2, v3,... can i do it?
    ###problem2 end#################

  2. #2
    Join Date
    Apr 2003
    Location
    Rosemount, MN
    Posts
    2,287
    for problem 2, I think you need to find the number of times v is in the string, so you can have the 1,2,3,4.... then you would just do a
    str_replace("v", "v$numer", $string);
    something like that.
    My settings

    Browser :: FireFox 1.5
    Resolution :: 1152x864
    Connection :: Cable Modem 2Mbs

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,151
    1:
    PHP Code:
    preg_match_all('/<abc>(.*)<efg>/Us'$string$matches);
    $values $matches[1];
    echo 
    "<pre>";
    print_r($values);
    echo 
    "</pre>"
    2:
    PHP Code:
    $counter 1;
    $newString preg_replace('/v/ie''"$0".$counter++'$string);
    echo 
    $newString
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles