Complex String Replace?

Discussion in 'PHP' started by glasglow, Jul 13, 2007.

  1. #1
    Is there any way to add a matching ending..

    str_replace(' '. $row2[$columnchoice] . ' ',$string);

    If the $string has a 002 then the $row used to replace should also have a 002
    if the $string has 003 then the $row used to replace should also have 003.
    But if the $string doesn't have 002 or 003 then the $row can't have 002 or 003 either... pulled from a random $row set of records.

    Any way to do that?


    ...This is added later.

    I have the logic.. I think..

    First the post comes into the script $_GET[] Then I need to identify whether or not that post has 002 or 003..Then I can just pass a variable onto the $query..

    Like if 002 is true then add a variable WHERE column LIKE '%002'
    OR
    if 003 is true then add a variable WHERE column LIKE '%003'
    OR
    if 002 and 003 are not true then WHERE column NOT LIKE '%002' AND '%003'

    But the problem is still in the match and identify from the GET...
     
    glasglow, Jul 13, 2007 IP