mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added examples do demonstrate uses with arrays, as well as the count parameter.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@135762 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
e041a07655
commit
5a0c95a2ac
1 changed files with 19 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.str-replace">
|
||||
<refnamediv>
|
||||
|
@ -62,11 +62,27 @@
|
|||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>str_replace</function> example</title>
|
||||
<title><function>str_replace</function> examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$bodytag = str_replace("%body%", "black", "<body text=%body%>");
|
||||
// Provides: <body text='black'>
|
||||
$bodytag = str_replace("%body%", "black", "<body text='%body%'>");
|
||||
|
||||
// Provides: Hll Wrld f PHP
|
||||
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
|
||||
$onlyconstants = str_replace($vowels, "", "Hello World of PHP");
|
||||
|
||||
// Provides: You should eat pizza, beer, and ice cream every day
|
||||
$phrase = "You should eat fruits, vegetables, and fiber every day.";
|
||||
$healthy = array("fruits", "vegetables", "fiber");
|
||||
$yummy = array("pizza", "beer", "ice cream");
|
||||
|
||||
$newphrase = str_replace($healthy, $yummy, $phrase);
|
||||
|
||||
// Use of the count parameter is available as of PHP 5.0.0
|
||||
$str = str_replace("ll", "", "good golly miss molly!", $count);
|
||||
echo $count; // 2
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
Loading…
Reference in a new issue