3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sweet = ['a' => 'apple ', 'b' => ' "banana" ']; $array = ['sweet' => $sweet, 'test' => " <a href='test'>Test</a>"]; array_walk_recursive($array, function(&$value) { $value = htmlspecialchars(trim($value)); } ); var_export($array);
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
array ( 'sweet' => array ( 'a' => 'apple', 'b' => '&quot;banana&quot;', ), 'test' => '&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;', )
Output for 7.1.26 - 7.1.33, 7.2.17 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
array ( 'sweet' => array ( 'a' => 'apple', 'b' => '&quot;banana&quot;', ), 'test' => '&lt;a href=\'test\'&gt;Test&lt;/a&gt;', )

preferences:
169.1 ms | 408 KiB | 5 Q