Tăierea șirurilor în PHP
substrmb_substrmb_strcutЗадание 1
Este dat șirul:
php<?php
$str = 'html css php';
?>
Decupați din șirul nostru și afișați pe ecran:
php'html'
'css'
'php'
Задание 2
Este dat șirul:
php<?php
$str = 'abcdefgh';
?>
Afișați ultimele 3 caractere:
php'fgh'
Задание 3
Este dat șirul:
php<?php
$str = 'http://example.com';
?>
Verificați dacă începe cu 'http://':
Задание 4
Este dat șirul:
php<?php
$str = 'https://example.com';
?>
Verificați dacă începe cu 'http://' sau 'https://':
Задание 5
Este dat șirul:
php<?php
$str = 'image.png';
?>
Verificați dacă se termină cu '.png':
Задание 6
Este dat șirul:
php<?php
$str = 'photo.jpg';
?>
Verificați dacă se termină cu '.png' sau '.jpg':
Задание 7
Este dat șirul:
php<?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:
php'This ...'
Задание 8
Este dat șirul:
php<?php
$str = 'многобайтовые строки требуют особого подхода';
?>
Decupați ultimul cuvânt:
php'подхода'
Задание 9
Este dat șirul:
php<?php
$str = 'пример работы с кириллическими символами';
?>
Decupați și afișați:
php'работы'
'кириллическими'