note 63591 deleted from function.strtr by bjori
| From: | bjori@php.net | Date: | Fri, 24 Mar 2006 19:35:40 +0000 |
| Subject: | note 63591 deleted from function.strtr by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106546@lists.php.net to get a copy of this message | ||
Note Submitter: james dot andres at gmail dot com
Reason: useless
----
I'm not sure if it has already been mentioned but I had one hell of a time working with the
dollar sign character and the shell (bash). Basically a dollar sign is a special char in the
terminal so there is a need to replace them in all your strings. There's a quite a few
gotchyas though.
Ex 1 ** DOES'NT WORK
<?php
$mystring = 'I want to make lots of $$ CACHE $$!';
$mystring = str_replace($mystring, '$', '/$');
// output: '//$'
?>
Ex 2 ** ALMOST THERE...
<?php
$mystring = 'I want to make more $$ CACHE $$!';
$mystring = strtr($mystring, '$', '/$');
// output: 'I want to make more // CACHE //!'
?>
Ex 3 ** GOT IT!
<?php
$mystring = 'I want to make the most $$ CACHE $$!';
$mystring = strtr($mystring, array('$', '/$'));
// output: 'I want to make the most /$/$ CACHE /$/$!'
?>