Recorte de Strings em PHP
substrmb_substrmb_strcutЗадание 1
Dada a string:
php<?php
$str = 'html css php';
?>
Recorte da nossa string e exiba na tela:
php'html'
'css'
'php'
Задание 2
Dada a string:
php<?php
$str = 'abcdefgh';
?>
Exiba os últimos 3 caracteres:
php'fgh'
Задание 3
Dada a string:
php<?php
$str = 'http://example.com';
?>
Verifique se ela começa com 'http://':
Задание 4
Dada a string:
php<?php
$str = 'https://example.com';
?>
Verifique se ela começa com 'http://' ou 'https://':
Задание 5
Dada a string:
php<?php
$str = 'image.png';
?>
Verifique se ela termina com '.png':
Задание 6
Dada a string:
php<?php
$str = 'photo.jpg';
?>
Verifique se ela termina com '.png' ou '.jpg':
Задание 7
Dada a string:
php<?php
$str = 'This is a long string';
?>
Se houver mais de 5 caracteres, exiba os primeiros 5 com reticências, caso contrário, exiba a string inteira:
php'This ...'
Задание 8
Dada a string:
php<?php
$str = 'многобайтовые строки требуют особого подхода';
?>
Recorte a última palavra:
php'подхода'
Задание 9
Dada a string:
php<?php
$str = 'пример работы с кириллическими символами';
?>
Recorte e exiba:
php'работы'
'кириллическими'