Elxis CMS Forum
Support => Technical support => Topic started 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
-
Yes it is OK, although it is not mandatory to use eUTF class in all situations. Somethimes simple explode is enough.
-
thank a lot :)
-
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);
-
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:
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;