abangbatax
asked on
hi again
see this again :
person1only--
person1only,person2only--
person1only,person2only,pe rson3only- -
person1only,person2only,pe rson3only, person4onl y--
person1only,person2only,pe rson3only, person4onl y,person5o nly--
person1only,person2only,pe rson3only, person4onl y,person5o nly,person 6only--
person1only,person2only,pe rson3only, person4onl y,person5o nly,person 6only,pers on7only--
now what i want is
some how in my script i get number 2 and 4
how to replace person2only and person4only with "nothere" by the return number that i get from my script?
person1only--
person1only,person2only--
person1only,person2only,pe
person1only,person2only,pe
person1only,person2only,pe
person1only,person2only,pe
person1only,person2only,pe
now what i want is
some how in my script i get number 2 and 4
how to replace person2only and person4only with "nothere" by the return number that i get from my script?
ASKER
$new_result = str_replace(array('person2 only','per son4only') ,'nothere' ,$result);
i think you almost get what i mean
ok, like this
$return = "2,4";
$string = person1only,person2only,pe rson3only, person4onl y,person5o nly,person 6only,pers on7only--
i want the output to be :
$output = "person1only,nothere,perso n3only,not here,perso n5only,per son6only,p erson7only --";
how? :D
i think you almost get what i mean
ok, like this
$return = "2,4";
$string = person1only,person2only,pe
i want the output to be :
$output = "person1only,nothere,perso
how? :D
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
tested or not ...... i hope it worked
ASKER
thank you! that exactly i want...
You can use str_replace() to replace substrings. Your big string is stored in $result:
$new_result = str_replace(array('person2
http://php.net/str_replace