Substr_replace funtion:

Substr_replace funtion:

Substr_replace is used to replace text within a portion of a string

Syntax : string substr_replace ( string string, string replacement, int start [, int length])

substr_replace() replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement. The result is returned.

Example :

<?php

$input = ‘Welcome user’;

echo “Input Text: $input<hr>\n”;

echo “Output Text: <br>\n”;

echo substr_replace($input, ‘john’, 7) . “<br>\n”;

echo substr_replace($input, ‘Hello’, 0, 7) . “<br>\n”;

?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.