anarchoi Posted March 5, 2008 Share Posted March 5, 2008 here is my code: $xi = $ix + 1; $one = array("2002", "12012", "13013", "17017"); $two = array("one", "two", "three", "four"); $realnames = str_replace($one, $two, $realnumbers); $realnumbers2 = $ix + 1; $realnumbers = $realnumbers2 * 1000 + $realnumbers2; echo "$realnames \n"; echo "<br>( $realnumbers )"; } else { // echo "Option $ix was NOT selected<br />\n"; // } } the replacements works, but the last entry isn't displayed (17017/four in this code) i.e. $realnumbers = 2002 12012 13013 17017 only the three first will be displayed/replaced as soon as i use str_replace with $realnumbers :/ ...weird Link to comment https://forums.phpfreaks.com/topic/94449-str_replace-multiple-replacements-error/ Share on other sites More sharing options...
anarchoi Posted March 5, 2008 Author Share Posted March 5, 2008 bump Link to comment https://forums.phpfreaks.com/topic/94449-str_replace-multiple-replacements-error/#findComment-484202 Share on other sites More sharing options...
bpops Posted March 5, 2008 Share Posted March 5, 2008 Is this inside another loop or something? On your fourth line, $realnames = str_replace($one, $two, $realnumbers); You're using $realnumbers but its not yet defined. Link to comment https://forums.phpfreaks.com/topic/94449-str_replace-multiple-replacements-error/#findComment-484203 Share on other sites More sharing options...
anarchoi Posted March 5, 2008 Author Share Posted March 5, 2008 yeah, i forgot to add the beginning of the script it's comming from $ix ... i am doing *1000 +$ix just so the numbers always look differents and its easier for the replacement (or else if i replace a 2 it would replace 222, 202, 12222, etc) $nbr = 21; $selected = $post[field7]; for($ix = 0; $ix < $nbr; $ix++) { if(pow(2, $ix) & $selected) { Link to comment https://forums.phpfreaks.com/topic/94449-str_replace-multiple-replacements-error/#findComment-484215 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.