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 ,
- Send mail to admin or website owner when ever the logs show 404 or 500 or 401 or 400 error codes
- Speed up wordpress using .htaccess part 2
- Warning: session_start(): Cannot send session cookie headers already sent
- Quick method to prevent cross site scripting in php
- Get DNS Record using PHP
- How to create random passwords using php
- Fix Too many connections mysql_connect
- Set xampp:- Apache Mysql Filezilla Mercury Tomcat as a windows service and get xampp to start automatically on boot up
- ScriptAlias and Alias in httpd.conf at a glance
- Using PHP_SELF best practices
