Tăierea șirurilor în PHP
Este dat șirul:
<?php
$str = 'html css php';
?>
Decupați din șirul nostru și afișați pe ecran:
'html'
'css'
'php'
Este dat șirul:
<?php
$str = 'abcdefgh';
?>
Afișați ultimele 3 caractere:
'fgh'
Este dat șirul:
<?php
$str = 'http://example.com';
?>
Verificați dacă începe cu 'http://':
Este dat șirul:
<?php
$str = 'https://example.com';
?>
Verificați dacă începe cu 'http://' sau 'https://':
Este dat șirul:
<?php
$str = 'image.png';
?>
Verificați dacă se termină cu '.png':
Este dat șirul:
<?php
$str = 'photo.jpg';
?>
Verificați dacă se termină cu '.png' sau '.jpg':
Este dat șirul:
<?php
$str = 'This is a long string';
?>
Dacă sunt mai multe de 5 caractere, afișați primele 5 cu puncte de suspensie, altfel afișați întregul șir:
'This ...'
Este dat șirul:
<?php
$str = 'многобайтовые строки требуют особого подхода';
?>
Decupați ultimul cuvânt:
'подхода'
Este dat șirul:
<?php
$str = 'пример работы с кириллическими символами';
?>
Decupați și afișați:
'работы'
'кириллическими'