String Cutting in PHP
substrmb_substrmb_strcutЗадание 1
Given a string:
php<?php
$str = 'html css php';
?>
Cut from our string and output:
php'html'
'css'
'php'
Задание 2
Given a string:
php<?php
$str = 'abcdefgh';
?>
Output the last 3 characters:
php'fgh'
Задание 3
Given a string:
php<?php
$str = 'http://example.com';
?>
Check that it starts with 'http://':
Задание 4
Given a string:
php<?php
$str = 'https://example.com';
?>
Check that it starts with 'http://' or 'https://':
Задание 5
Given a string:
php<?php
$str = 'image.png';
?>
Check that it ends with '.png':
Задание 6
Given a string:
php<?php
$str = 'photo.jpg';
?>
Check that it ends with '.png' or '.jpg':
Задание 7
Given a string:
php<?php
$str = 'This is a long string';
?>
If there are more than 5 characters, output the first 5 with an ellipsis, otherwise output the entire string:
php'This ...'
Задание 8
Given a string:
php<?php
$str = 'многобайтовые строки требуют особого подхода';
?>
Cut the last word:
php'подхода'
Задание 9
Given a string:
php<?php
$str = 'пример работы с кириллическими символами';
?>
Cut and output:
php'работы'
'кириллическими'