I have a problem with getting a substring of this string:
GMOクラウドの芦田です。前回、OpenSocialに対応したSNSの「OpenPNE」をインストールしたので、今回はソーシャルアプリを作ってOpenPNE上で公開してみます。また、作ったアプリをmixiアプリとしてmixiにも登録してみましょう。
I just wanted to display up to nth character or at least does not display broken/incomplete words.
at first i tried.
$content = "GMOクラウドの芦田です。前回、OpenSocialに対応したSNSの「OpenPNE」をインストールしたので、今回はソーシャルアプリを作ってOpenPNE上で公開してみます。また、作ったアプリをmixiアプリとしてmixiにも登録してみましょう。";
$content = mb_substr($content, 0, 10, 'UTF-8');
but it results to:
GMOクラウドの芦田です。前回、OpenSo
the word is not complete
i also tried using regex:
$content = "GMOクラウドの芦田です。前回、OpenSocialに対応したSNSの「OpenPNE」をインストールしたので、今回はソーシャルアプリを作ってOpenPNE上で公開してみます。また、作ったアプリをmixiアプリとしてmixiにも登録してみましょう。";
if (preg_match('/^.{1,40}\b/s', $content, $match))
{
print_r($match);
}
resulted to:
Array ( [0] =>GMO )
what could have been done to get something like
GMOクラウドの芦田です。前回、OpenSocial
word should be complete. is there an mb_ function in php i could use to accomplish this?