Facebook Twitter Reset

This Tutorial Has Been Viewed 2,380 Times.

Replacing a string using php

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′$var1); // outputs ’123def abcdef abcdef’
?>

VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

Incoming search terms:




You will also be interested in ,

No comments yet.

Leave a Comment

Spam protection by WP Captcha-Free

Affordable Seo PackagesSeo BlogEdu Backlinks
More in C# (3 of 5 articles)