There is a line: Главная>Новости>Новость 1 .
It is necessary to cut the line before the last character > , so that only Новость 1 remains.
How to do this with php ?
There is a line: Главная>Новости>Новость 1 .
It is necessary to cut the line before the last character > , so that only Новость 1 remains.
How to do this with php ?
You yourself could easily cope with this task if you decompose it into its components (this is called decomposition):
Cut the string after it
$pos = strrpos($str, '>'); if (!$pos !== false) { $str = substr($str, $pos + 1); } or
Get the last (length - 1) array element
$bits = explode('>', $str); $str = $bits[sizeof($bits) - 1]; Bonus - magic odnogoschnik
return explode('>', $str)[substr_count('>', $str) - 1]; array_pop(explode('>', $str)) shorter. - VismanSource: https://ru.stackoverflow.com/questions/445624/
All Articles