pibebueno Posted January 27, 2010 Share Posted January 27, 2010 The idea is that "% 1 $ s" is replaced by"%1$s". Very simple but does not go =( <?php $linea = "% 1 $ s"; $linea = ereg_replace("% 1 $ s","%1$s", $linea); echo $linea; ?> Please if anyone knows what I did not do well might help me? Link to comment https://forums.phpfreaks.com/topic/190041-replace-a-string-the-code-does-not-go-well-written-but/ Share on other sites More sharing options...
taquitosensei Posted January 27, 2010 Share Posted January 27, 2010 can you just remove the spaces? $linea="% 1 $ S"; $linea=str_replace(" ","", $linea); Link to comment https://forums.phpfreaks.com/topic/190041-replace-a-string-the-code-does-not-go-well-written-but/#findComment-1002635 Share on other sites More sharing options...
roopurt18 Posted January 27, 2010 Share Posted January 27, 2010 $ has a special meaning inside double-quoted strings. $s = '1234'; echo "asdf$s"; echo "\n"; echo 'asdf$s' Link to comment https://forums.phpfreaks.com/topic/190041-replace-a-string-the-code-does-not-go-well-written-but/#findComment-1002640 Share on other sites More sharing options...
pibebueno Posted January 27, 2010 Author Share Posted January 27, 2010 Thnk you guys but don't work on ereg_replace. please help :'( <?php $Cadena='$ s'; $CadenaMod=ereg_replace('$ s','$s',$Cadena); echo $CadenaMod; ?> Link to comment https://forums.phpfreaks.com/topic/190041-replace-a-string-the-code-does-not-go-well-written-but/#findComment-1002716 Share on other sites More sharing options...
Alex Posted January 27, 2010 Share Posted January 27, 2010 Use str_replace instead. Link to comment https://forums.phpfreaks.com/topic/190041-replace-a-string-the-code-does-not-go-well-written-but/#findComment-1002717 Share on other sites More sharing options...
pibebueno Posted January 28, 2010 Author Share Posted January 28, 2010 Than! <?php $antes = array('$ s'); $despues = array('$s'); $text = '$ s jlkhdsakjdshkajdshkasjdh'; $output = str_replace($antes, $despues, $text); echo $output; ?> Link to comment https://forums.phpfreaks.com/topic/190041-replace-a-string-the-code-does-not-go-well-written-but/#findComment-1002732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.