<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>str_replace &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/tag/str_replace/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mudbest.com</link>
	<description>行影不离,忘之却步.</description>
	<lastBuildDate>Mon, 01 Oct 2012 12:32:17 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>
	<item>
		<title>PHP中str_replace函数使用数组</title>
		<link>https://www.mudbest.com/php%e4%b8%adstr_replace%e5%87%bd%e6%95%b0%e4%bd%bf%e7%94%a8%e6%95%b0%e7%bb%84/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Mon, 20 Jun 2011 09:30:28 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[str_replace]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=676</guid>

					<description><![CDATA[函数原型： needle：要被替换的字符串，new_needle：替换用的字符串，haystack：操作字符串 ... <a title="PHP中str_replace函数使用数组" class="read-more" href="https://www.mudbest.com/php%e4%b8%adstr_replace%e5%87%bd%e6%95%b0%e4%bd%bf%e7%94%a8%e6%95%b0%e7%bb%84/" aria-label="阅读 PHP中str_replace函数使用数组">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>函数原型：</p>
<pre class="brush: php; title: ; notranslate">
mixed str_replace(mixed needle,mixed new_needle,mixed haystack&#x5B;,int &amp;count]);
</pre>
<p>needle：要被替换的字符串，new_needle：替换用的字符串，haystack：操作字符串，count：替换次数【可选参数】<br />
我们重点试验前三个在使用数组是的执行方式：</p>
<p>      在都不使用数组时，该函数直接使用new_needle替换所有的needle并返回替换后的字符串。<br />
如：</p>
<pre class="brush: php; title: ; notranslate">
str_replace(&quot;m&quot;,&quot;n&quot;,&quot;my name is jim!&quot;)返回ny nane is jin!
</pre>
<p>     1、只对needle使用数组。<br />
     示例：<span id="more-676"></span></p>
<pre class="brush: php; title: ; notranslate">
str_replace(array('m','i'),'n',&quot;my name is jim!&quot;);
</pre>
<p>返回：ny nane ns jnn!<br />
     可以看出，函数顺序性的对数组中每个字符串进行替换，并返回替换后的字符串。<br />
      2、只对new_needle使用数组。<br />
     示例：</p>
<pre class="brush: php; title: ; notranslate">
str_replace('m',array('n','z'),&quot;my name is jim!\n&quot;)
</pre>
<p>返回：Arrayy naArraye is jiArray!<br />
      该替换比较有意思，如果只对第二个参数使用数组则函数将其作为字符串Array进行使用，将所有的needle替换为了数组。<br />
     3、只对haystack使用数组。<br />
     示例：</p>
<pre class="brush: php; title: ; notranslate">
str_replace(&quot;m&quot;,&quot;n&quot;,array(&quot;my name is jim!&quot;,&quot;the game is over!&quot;));
</pre>
<p>该语句执行结果返回一个数组，即分别为传入的两个字符串替换后的结果。<br />
     如果输出数组内容会看到：ny nane is jin! the gane is over!</p>
<p>     4、对needle和new_needle都使用数组。<br />
     示例：</p>
<pre class="brush: php; title: ; notranslate">
str_replace(array(&quot;m&quot;,&quot;i&quot;),array(&quot;n&quot;,&quot;z&quot;),&quot;my name is jim!&quot;);
</pre>
<p>返回：ny nane zs jzn!<br />
      查看执行结果可以发现，如果前两个参数都使用数组则函数把数组各个对象项字符串进行了替换，及needle的第一项替换为new_needle的第一项。以此类推。<br />
      如 果needle数组比new_deedle长，例 如：</p>
<pre class="brush: php; title: ; notranslate">
str_replace(array(&quot;m&quot;,&quot;i&quot;,&quot;s&quot;),array(&quot;n&quot;,&quot;z&quot;),&quot;my name is jim!&quot;);
</pre>
<p>返回：ny nane z jzn!可见，对于needle数组多出来的字符串被替换为了空串。<br />
     如果new_needle数组比needle长，例 如：</p>
<pre class="brush: php; title: ; notranslate">
str_replace(array(&quot;m&quot;,&quot;i&quot;),array(&quot;n&quot;,&quot;z&quot;,&quot;x&quot;),&quot;my name is jim!&quot;);
</pre>
<p>返回ny nane zs jzn!可见new_needle多余的项被忽略。<br />
     5、三个参数都使用数组。<br />
     例如：</p>
<pre class="brush: php; title: ; notranslate">
str_replace(array(&quot;m&quot;,&quot;i&quot;),array(&quot;n&quot;,&quot;z&quot;),array(&quot;my name is jim!&quot;,&quot;the game is over&quot;));
</pre>
<p>返回的数组内容：ny nane zs jzn!the gane zs over<br />
     这个比较好理解，对两个字符串分别执行替换。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>str_replace替换函数</title>
		<link>https://www.mudbest.com/str_replace%e6%9b%bf%e6%8d%a2%e5%87%bd%e6%95%b0/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 12 Mar 2011 15:47:19 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[str_replace]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=463</guid>

					<description><![CDATA[function Quote_replaces($quote){ $quote = str_replace(' ... <a title="str_replace替换函数" class="read-more" href="https://www.mudbest.com/str_replace%e6%9b%bf%e6%8d%a2%e5%87%bd%e6%95%b0/" aria-label="阅读 str_replace替换函数">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<pre class="brush: php; title: ; notranslate">
function Quote_replaces($quote){
	$quote = str_replace('{quote}','&lt;div class=&quot;decmt-box&quot;&gt;',$quote);
	$quote = str_replace('{title}','&lt;div class=&quot;decmt-title&quot;&gt;&lt;span class=&quot;username&quot;&gt;',$quote);
	$quote = str_replace('{/title}','&lt;/span&gt;&lt;/div&gt;',$quote);
	$quote = str_replace('&amp;lt;br/&amp;gt;','&lt;br&gt;',$quote);
             $quote = str_replace('&amp;lt;', '&lt;', $quote);
	$quote = str_replace('&amp;gt;', '&gt;', $quote);
	$quote = str_replace('{content}','&lt;div class=&quot;decmt-content&quot;&gt;',$quote);
	$quote = str_replace('{/content}','&lt;/div&gt;',$quote);
	$quote = str_replace('{/quote}','&lt;/div&gt;',$quote);
//	echo $quote;
  return $quote;
}
</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
