Home  >  Article  >  Backend Development  >  Usage example of regular replacement function ereg_replace in php_PHP tutorial

Usage example of regular replacement function ereg_replace in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:11:24963browse

Usage examples of the regular replacement function ereg_replace in php

The following example is to use the regular replacement function ereg_replace in php to replace the specified characters with the character examples I want. The code is as follows:

The code is as follows:

$num = 'www.jb51.net';
$string = "this string has four words.
";
$string = ereg_replace ('four', $num, $string);
echo $string;

$num = '49';
$string = "this string has four words";
$string = ereg_replace ('four', $num, $string);
echo $string;

$string ="Test text";
echo "**********$string************

";
$string = ereg_replace ("^", "
", $string);
$string = ereg_replace ("$", "
", $string);
echo "==========$string==========";

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/930077.htmlTechArticleUsage examples of the regular replacement function ereg_replace in php. The following example uses the regular replacement function ereg_replace in php to replace the specified characters. Into the character example I want, the code is as follows: Code...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn