Simple code to replace a string using a very simple approach.
You can’t do this with ereg_replace, but you can with preg_replace.
<?
$var = ‘abcdef abcdef abcdef’;
// pattern, replacement, string
echo ereg_replace(‘abc’, ’123′, $var); // outputs ’123def 123def 123def’
// pattern, replacement, string, limit
echo preg_replace(‘/abc/’, ’123′, $var, 1); // outputs ’123def abcdef abcdef’
?>
Incoming search terms:
You will also be interested in ,
- Locking a text file database using php
- Sort MYSQL data according to the date in php or mysql itself
- Caching of web page using php
- Find Absolute Path Of A File Or Directory Using PHP
- Date in title bar using php
- Count distinct records or values and display it using mysql and php
- Remote Mysql Connection From CPANEL And Connect To MYSQL Database From Your Local Webserver or Other External Web Server
- Quick method to prevent cross site scripting in php
- Creating a simple class file using PHP
- Mysql backup via cron using php and email the file

