3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function decodeText($texts) { if(is_array($texts)) { $encoded = array(); foreach($texts as $key => $text) { if (!is_array($key)) { $encoded[$key] = utf8_decode($text); } else { decodeText($text); } } } else { $encoded = utf8_decode($text); } return $encoded; } $smth = array('test' => 'ääõölö', 'test2' => array('öüõü', 'dasd212äöäöä' )); $smth = decodeText($smth); var_dump($smth); var_dump(decodeText('köõöõüpõ'));
Output for 5.3.0 - 7.1.0
Warning: utf8_decode() expects parameter 1 to be string, array given in /in/BdVGD on line 12 array(2) { ["test"]=> string(6) "��l�" ["test2"]=> NULL } Notice: Undefined variable: text in /in/BdVGD on line 22 string(0) ""
Output for 5.0.4 - 5.2.17
Notice: Array to string conversion in /in/BdVGD on line 12 array(2) { ["test"]=> string(6) "��l�" ["test2"]=> string(5) "Array" } Notice: Undefined variable: text in /in/BdVGD on line 22 string(0) ""
Output for 4.3.0 - 5.0.3
Notice: Array to string conversion in /in/BdVGD on line 12 array(2) { ["test"]=> string(6) "��l�" ["test2"]=> string(5) "Array" } Notice: Undefined variable: text in /in/BdVGD on line 22 string(0) ""