Quick actions

cmd+k|ctrl+k

Navigation

Languages

test_array_walk

Snippet info

Language

Php

Visibility

public

Author

fenghestudio

Created

2020-01-07T00:30:27Z

Updated

2020-01-07T00:30:27Z

<?php

$fruits = array("d" =>
 "lemon", "a" =>
 "orange", "b" =>
 "banana", "c" =>
 "apple");

function test_alter(&$item1, $key, $prefix)
{
    $item1 = "$prefix: $item1";

}
function test_print($item2, $key)
{
    echo "$key. $item2<
br />
\n";

}
echo "Before ...:\n";

array_walk($fruits, 'test_print');

array_walk($fruits, 'test_alter', 'fruit');

echo "... and after:\n";

array_walk($fruits, 'test_print');

?>
INFO