phparrayshtml-entities

applying a Function to Each element in an array (O'Reilly cookbook example)


for nested data.

I tried

<?php

$names = array('firstnames' => array("Baba", "Billy"),
'lastnames' => array("O'Riley", "O'Reilly"));

array_walk_recursive($names, function (&value, $key) {
    $value = htmlentities($value, ENT_QOUTES);
})

foreach ($names as $nametypes) {
    foreach ($nametypes as $name) {
        print "$name\n";

    }
}



?>

(An example from the book O'reilly PHP Cookbook 3rd Edition) page 148

but I keep getting a message

T_String, expecting T_Variable


Solution

  • use &$value instead of &value use ENT_QUOTES instead of ENT_QOUTES