Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular

PHPize.online is a free online environment for quickly running, experimenting with and sharing PHP (including Carbon extension for DateTime) and SQL code. You can run your SQL code with PHP code that can use the same DB. For database manipulations you can use pre-defined instances of PDO ($pdo), mysqli ($mysqli) & Laravel query builder ($db)

Copy Format Clear
Copy Clear
Copy Format Clear
<?php function reverse_vowels($word) { // получаем строку всех гласных букв в слове $vowels = implode( // объединяем массив в строку array_filter(// получаем массив всех гласных букв в слове str_split($word), // разбиваем слово на буквы function ($c) { // проверяем если буква гласная [ayeiou] return preg_match("/[ayeiou]/i", $c); } ) ); echo "строкa всех гласных букв в слове: " . $vowels . PHP_EOL; $v = 0; $reverse = implode(// объединяем массив в строку array_map( function ($i) use ($word, $vowels, &$v) {// &$v переменная переданная по ссылке $is_vowel = preg_match("/[ayeiou]/", $word[$i]); return $is_vowel ? $vowels[strlen($vowels) - 1 - $v++] : $word[$i]; }, range(0, strlen($word) - 1) // массив [0, количество букв в слове - 1] ) ); return $reverse; } echo reverse_vowels('environment');
Show:  
Copy Clear