<?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>programming - TsupamaN.com</title>
	<atom:link href="https://www.tsupaman.com/tag/programming/feed" rel="self" type="application/rss+xml" />
	<link>https://www.tsupaman.com/tag/programming</link>
	<description>ทำเว็บไซต์ด้วย Wordpress</description>
	<lastBuildDate>Fri, 07 Oct 2016 11:13:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>[PHP] แบ่งข้อความเป็น Array ด้วยฟังก์ชั่น strlen(), substr() แบบ UTF-8 และภาษาไทย</title>
		<link>https://www.tsupaman.com/2016/10/php-split-%e0%b8%82%e0%b9%89%e0%b8%ad%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1-%e0%b9%84%e0%b8%97%e0%b8%a2-utf-8</link>
		
		<dc:creator><![CDATA[TsupamaN]]></dc:creator>
		<pubDate>Mon, 10 Oct 2016 01:30:12 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php split ข้อความ]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ฟังก์ชั่น strlen]]></category>
		<category><![CDATA[แบ่งข้อความเป็น Array]]></category>
		<guid isPermaLink="false">https://www.tsupaman.com/?p=2359</guid>

					<description><![CDATA[<p>ข้อมูลต่อไปนี้ ผมไปเจอมาจากเว็บไซต์ Thaicreate.com ซึ่งเป็นเครดิตของคุณ Peter Sticker ได้โพสเอาไว้ ผมได้เอามาใช้งานกับงานจริงเห็นว่ามีประโยชน์มาก และคิดว่าคงเอามาใช้บ่อยๆ เลยขอเอามาโพสเก็บไว้ เผื่อวันไหนใช้งานจะได้สะดวก และหากมีการปรับปรุง จะได้ใส่ไว้ที่เดียวกันครับ ฟังก์ชั่น getMBStrSplit() ฟังก์ชั่นสำหรับแบ่งข้อความเป็น Array (ปกติใช้ str_split() แต่สำหรับภาษาไทยแบบ UTF-8 จะมีปัญหาการแบ่ง) // Convert a string to an array with multibyte string function getMBStrSplit($string, $split_length = 1){ mb_internal_encoding('UTF-8'); mb_regex_encoding('UTF-8'); $split_length = ($split_length &#60;= 0) ? 1 : $split_length; $mb_strlen = mb_strlen($string, 'utf-8'); $array = array(); [&#8230;]</p>
<p>The post <a href="https://www.tsupaman.com/2016/10/php-split-%e0%b8%82%e0%b9%89%e0%b8%ad%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1-%e0%b9%84%e0%b8%97%e0%b8%a2-utf-8">[PHP] แบ่งข้อความเป็น Array ด้วยฟังก์ชั่น strlen(), substr() แบบ UTF-8 และภาษาไทย</a> appeared first on <a href="https://www.tsupaman.com">TsupamaN.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>ข้อมูลต่อไปนี้ ผมไปเจอมาจากเว็บไซต์ Thaicreate.com ซึ่งเป็นเครดิตของคุณ <strong><a title="View profile." href="http://www.thaicreate.com/member-profile/uid-042871.html" target="_blank" rel="nofollow">Peter Sticker</a></strong> ได้โพสเอาไว้ ผมได้เอามาใช้งานกับงานจริงเห็นว่ามีประโยชน์มาก และคิดว่าคงเอามาใช้บ่อยๆ เลยขอเอามาโพสเก็บไว้ เผื่อวันไหนใช้งานจะได้สะดวก และหากมีการปรับปรุง จะได้ใส่ไว้ที่เดียวกันครับ</p>
<h3><strong>ฟังก์ชั่น</strong> <strong>getMBStrSplit()</strong></h3>
<p>ฟังก์ชั่นสำหรับแบ่งข้อความเป็น Array (ปกติใช้ str_split() แต่สำหรับภาษาไทยแบบ UTF-8 จะมีปัญหาการแบ่ง)</p>
<pre class="lang:php decode:true " title="getMBStrSplit()">// Convert a string to an array with multibyte string
function getMBStrSplit($string, $split_length = 1){
	mb_internal_encoding('UTF-8');
	mb_regex_encoding('UTF-8'); 
	
	$split_length = ($split_length &lt;= 0) ? 1 : $split_length;
	$mb_strlen = mb_strlen($string, 'utf-8');
	$array = array();
	$i = 0; 
	
	while($i &lt; $mb_strlen)
	{
		$array[] = mb_substr($string, $i, $split_length);
		$i = $i+$split_length;
	}
	
	return $array;
}</pre>
<p>รายละเอียด</p>
<pre class="lang:php decode:true ">array getMBStrSplit ( string $string [, int $split_length = 1 ] )</pre>
<p><strong>string :</strong> ข้อความที่ต้องการนำมาแบ่ง</p>
<p><strong>split_length :</strong> จำนวนความยาวของตัวอักษรที่จะแบ่ง (ค่าปริยายคือ 1)</p>
<h3>ตัวอย่างการใช้ getMBStrSplit()</h3>
<pre class="lang:php decode:true " title="getMBStrSplit">$str = "สวัสดีชาวโลก";

$arr1 = getMBStrSplit($str);
$arr2 = getMBStrSplit($str, 3);

print_r($arr1);
print_r($arr2);

หรือ

$arrDescription = getMBStrSplit($overview, 150);
echo $arrDescription[0];
</pre>
<p>ลองเอาไปใช้งานกันดูครับ ชอบมาก ขอบคุณคุณ <strong>Peter Sticker</strong> จาก Thaicreate อีกทีครับ</p>
<p>The post <a href="https://www.tsupaman.com/2016/10/php-split-%e0%b8%82%e0%b9%89%e0%b8%ad%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1-%e0%b9%84%e0%b8%97%e0%b8%a2-utf-8">[PHP] แบ่งข้อความเป็น Array ด้วยฟังก์ชั่น strlen(), substr() แบบ UTF-8 และภาษาไทย</a> appeared first on <a href="https://www.tsupaman.com">TsupamaN.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
