<?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>中英文 &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/tag/%E4%B8%AD%E8%8B%B1%E6%96%87/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mudbest.com</link>
	<description>行影不离,忘之却步.</description>
	<lastBuildDate>Mon, 01 Oct 2012 08:03:42 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.1</generator>
	<item>
		<title>php中英文企业站解决方案</title>
		<link>https://www.mudbest.com/php%e4%b8%ad%e8%8b%b1%e6%96%87%e4%bc%81%e4%b8%9a%e7%ab%99%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Tue, 10 Apr 2012 08:12:46 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[中英文]]></category>
		<category><![CDATA[反序列化]]></category>
		<category><![CDATA[多语言]]></category>
		<category><![CDATA[序列化]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1033</guid>

					<description><![CDATA[假设表： id (tinyint) title (varchar 100) content (text) 从这 ... <a title="php中英文企业站解决方案" class="read-more" href="https://www.mudbest.com/php%e4%b8%ad%e8%8b%b1%e6%96%87%e4%bc%81%e4%b8%9a%e7%ab%99%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88/" aria-label="阅读 php中英文企业站解决方案">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>假设表：<br />
id (tinyint)<br />
title (varchar 100)<br />
content (text)</p>
<p>从这个简单的例子，如果要用到中文和英文，那就可以把2者同时的存入到 title 和 content 字段中。<br />
例子：<span id="more-1033"></span></p>
<pre class="brush: php; title: ; notranslate">
$title = array('zh'=&gt;'标题','en'=&gt;'title');
</pre>
<p>就title一个字段里相当于是存入了这样的一个数组进去，但是如果要存数组，就需要将它进行序列化。<br />
那么:</p>
<pre class="brush: php; title: ; notranslate">
$title = serialize(array('zh'=&gt;'标题','en'=&gt;'title'));
//结果a:2:{s:2:&quot;zh&quot;;s:6:&quot;标题&quot;;s:2:&quot;en&quot;;s:5:&quot;title&quot;;}
</pre>
<p>添加都好处理，主要是编辑这一步。其实也没那么麻烦，只要明白了数组重组的道理就好办了。<br />
来一个例子。</p>
<pre class="brush: php; title: ; notranslate">
$ss= 'a:2:{s:2:&quot;zh&quot;;s:6:&quot;123123&quot;;s:2:&quot;en&quot;;s:12:&quot;sdfsdfsdfsdf&quot;;}';
$aa = unserialize($ss);
//print_r($aa);
//exit;
$tt = Array ( 'zh' =&gt; '123123' ,'en' =&gt; 'sdfsdfsdfsdf' );
$ttt = array('zh'=&gt;'ssssss');
$rs = array_merge($tt,$ttt);
//print_r($rs);
</pre>
<p>从上面的例子可以看出，只是在于数组重组这一步的操作，数组$tt里面的zh值被$ttt的zh值所覆盖，这样就实现了编辑的效果。</p>
<p>在处理字段的时候可用到以下这个简单的序列化重组的函数：</p>
<pre class="brush: php; title: ; notranslate">
//1:传递来的字符串  表单
//2:数组的键 标识符 例如 'zh'=&gt;
//3 oldstr 是已经被序列化的字符串 数据库查询返回的字段值
function s_serialize($str,$key,$oldstr){
			         $str =array(
			           $key =&gt; $str
			         );
		$array_str = array_merge(unserialize($oldstr),unserialize(serialize($str)));
		$array_str = serialize($array_str);
		return $array_str;
}
</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
