<?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>春去花还在-CoLee★＂ &#187; 字符串替换函数</title>
	<atom:link href="http://colee.99n9.com/tag/%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%9b%bf%e6%8d%a2%e5%87%bd%e6%95%b0/feed/" rel="self" type="application/rss+xml" />
	<link>http://colee.99n9.com</link>
	<description>CoLee的网页设计制作素材、html、javacript、ajax代码精心自编或修改收藏，欢迎大家共享与交流。</description>
	<lastBuildDate>Tue, 04 Aug 2009 03:51:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>字符串替换函数str_replace使用帮助</title>
		<link>http://colee.99n9.com/%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%9b%bf%e6%8d%a2%e5%87%bd%e6%95%b0str_replace%e4%bd%bf%e7%94%a8%e5%b8%ae%e5%8a%a9/</link>
		<comments>http://colee.99n9.com/%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%9b%bf%e6%8d%a2%e5%87%bd%e6%95%b0str_replace%e4%bd%bf%e7%94%a8%e5%b8%ae%e5%8a%a9/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 02:19:11 +0000</pubDate>
		<dc:creator>CoLee★＂</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[str_replace]]></category>
		<category><![CDATA[字符串替换函数]]></category>

		<guid isPermaLink="false">http://colee.99n9.com/?p=61</guid>
		<description><![CDATA[str_replace函数
功能: 字符串替换
语法: string str_replace(string needle, string str, string haystack);
返回值: 字符串
函数种类: 字符串处理
本函数将字符串 str 代入 haystack 字符串中，将所有的 needle 置换成 str。mlevine@adtraq.com (11-Apr-1999) 指出在 PHP 3.0.7 版，本函数有些 bug，而 nadeem@bleh.org (05-Jun-1999) 补充在 PHP 3.0.8 版本函数就回复正常了。
使用范例

下例将 %body% 以 black 取代
&#60; php
$bodytag = str_replace(&#8221;%body%&#8221;, &#8220;black&#8221;, &#8220;&#60;body text=%body%&#62;&#8221;);
echo $bodytag;
&#62;
格式：
[@str_replace("要替换的旧内容", "要取代原内容的新字符", $被替换内容的变量名)]
[@str_replace(array('旧1','旧2','旧3'), array('新1','新2','新3'), $被替换内容的变量名)]
[@str_replace(array('旧1','旧2','旧3'), '新内容', $被替换内容的变量名)]
实例：
多对一替换：想把内容字段里所有的&#60;p&#62;&#60;/p&#62;标签清除掉,替换成空
[@str_replace(array('&#60;p&#62;','&#60;/p&#62;'), '', $Content)]
一对一替换：想把内容字段里所有的&#60;br&#62;标签换成&#60;p&#62;
[@str_replace('&#60;br&#62;', '&#60;p&#62;', $Content)]
多对多替换：想把内容字段里的&#60;br&#62;换成&#60;br /&#62;, 同时&#60;p&#62;换&#60;hr&#62;，把&#60;/p&#62;全清除
[@str_replace(array('&#60;br&#62;', '&#60;p&#62;','&#60;/p&#62;'), array('&#60;br [...]]]></description>
			<content:encoded><![CDATA[<p>str_replace函数</p>
<p>功能: 字符串替换</p>
<p>语法: string str_replace(string needle, string str, string haystack);</p>
<p>返回值: 字符串</p>
<p>函数种类: 字符串处理</p>
<p>本函数将字符串 str 代入 haystack 字符串中，将所有的 needle 置换成 str。mlevine@adtraq.com (11-Apr-1999) 指出在 PHP 3.0.7 版，本函数有些 bug，而 nadeem@bleh.org (05-Jun-1999) 补充在 PHP 3.0.8 版本函数就回复正常了。</p>
<p>使用范例</p>
<p><a id="entrymore" name="entrymore"></a></p>
<p>下例将 %body% 以 black 取代</p>
<p>&lt; php</p>
<p>$bodytag = str_replace(&#8221;%body%&#8221;, &#8220;black&#8221;, &#8220;&lt;body text=%body%&gt;&#8221;);</p>
<p>echo $bodytag;</p>
<p>&gt;</p>
<p>格式：</p>
<p>[@str_replace("要替换的旧内容", "要取代原内容的新字符", $被替换内容的变量名)]</p>
<p>[@str_replace(array('旧1','旧2','旧3'), array('新1','新2','新3'), $被替换内容的变量名)]</p>
<p>[@str_replace(array('旧1','旧2','旧3'), '新内容', $被替换内容的变量名)]</p>
<p>实例：</p>
<p>多对一替换：想把内容字段里所有的&lt;p&gt;&lt;/p&gt;标签清除掉,替换成空</p>
<p>[@str_replace(array('&lt;p&gt;','&lt;/p&gt;'), '', $Content)]</p>
<p>一对一替换：想把内容字段里所有的&lt;br&gt;标签换成&lt;p&gt;</p>
<p>[@str_replace('&lt;br&gt;', '&lt;p&gt;', $Content)]</p>
<p>多对多替换：想把内容字段里的&lt;br&gt;换成&lt;br /&gt;, 同时&lt;p&gt;换&lt;hr&gt;，把&lt;/p&gt;全清除</p>
<p>[@str_replace(array('&lt;br&gt;', '&lt;p&gt;','&lt;/p&gt;'), array('&lt;br /&gt;','&lt;hr&gt;',''), $Content)]</p>
]]></content:encoded>
			<wfw:commentRss>http://colee.99n9.com/%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%9b%bf%e6%8d%a2%e5%87%bd%e6%95%b0str_replace%e4%bd%bf%e7%94%a8%e5%b8%ae%e5%8a%a9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
