Elxis CMS Forum

Support => Technical support => Topic started by: speck on May 23, 2010, 17:56:06

Title: A question about eUTF::utf8 [SOLVED]
Post by: speck on May 23, 2010, 17:56:06
i need to do something like this:
$descr = explode( '.' , $row->description);
$description = $descr[0].'.';
echo $description;

is right to use
$descr = eUTF::utf8_explode( '.' , $row->description);
$description = $descr[0].'.';
echo $description;

thanks for the help  ;D
            
Title: Re: A question about eUTF::utf8
Post by: Ivan Trebješanin on May 23, 2010, 20:18:57
Yes it is OK, although it is not mandatory to use eUTF class in all situations. Somethimes simple explode is enough.
Title: Re: A question about eUTF::utf8
Post by: speck on May 23, 2010, 23:08:40
thank a lot  :)
Title: Re: A question about eUTF::utf8
Post by: datahell on May 24, 2010, 12:25:58
Better use preg_split
preg_split('/\./', $row->description);

or if you want to get the first sentence of the text (as I believe you want) you can also use something like this:

$pos = $eUTF::utf8_strpos($row->description, '.');
$description = ($pos === false) ? $row->description : eUTF::utf8_substr($row->description, 0, $pos);
Title: Re: A question about eUTF::utf8
Post by: speck on May 24, 2010, 17:49:48
thanks joannis.
But i think i use $eUTF::utf8_explode.
I've tried all two solutions but I saw explode it works better because i need to break the $row->description also at the first <br /> or the first </p>, depends from the user's selection.

the code is so:

Code: [Select]
switch ($type_introtext) {
case 0: $symbol = ''; break;
case 1: $symbol = '.'; break;
case 2: $symbol = '<br />'; break;
case 3: $symbol = '</p>'; break;
}
...............
...............
if ($symbol) {
   $descr = eUTF::utf8_explode($symbol, $row->description);
   ($symbol == '.') ? $description = $descr[0]. '.' : $description = $descr[0];
}else{
   if($textlimit != '0') {
         $description =  eUTF::utf8_substr(strip_tags($row->description),0,$textlimit) .' ...';
   } else {
         $description = $row->description;
   }
}

echo $description;