String Parts in PHP
Given a string:
<?php
$str = 'ab-cd-ef';
?>
Using the strchr function,
output the following string to the screen:
'-cd-ef'
Given a string:
<?php
$str = 'ab-cd-ef';
?>
Using the strrchr function,
output the following string to the screen:
'-ef'
Given a string:
<?php
$str = 'ab--cd--ef';
?>
Using the strstr function,
output the following string to the screen:
'--cd--ef'
Given a string:
<?php
$str = 'программирование-на-php';
?>
Using the mb_strrchr function,
output the part of the string after the last hyphen:
'-php'
Given a string:
<?php
$str = 'Привет-Мир-Пока';
?>
Using the mb_strrichr function (case-insensitive)
find the substring starting from the first occurrence of 'мир':
'-Мир-Пока'
Given a string:
<?php
$str = 'Функции-для-работы-со-строками';
?>
Using the mb_strstr function,
output the part of the string starting from the first occurrence of 'работы':
'-работы-со-строками'
Given a string:
<?php
$str = 'ппп ррр ссс ттт ууу';
?>
Using mb_stristr, find the substring starting from 'РРР' (case-insensitive).
'ррр ссс ттт ууу'
Given a string:
<?php
$str = 'Тестирование-многобайтовых-функций';
?>
Using the mb_strrchr function,
output the part of the string after the last hyphen:
'-функций'
Given a string:
<?php
$str = 'Пример-Поиска-Подстроки-В-Тексте';
?>
Using the mb_strrichr function (case-insensitive)
find the substring starting from the first occurrence of 'тексте':
'-В-Тексте'