I have an array as follow
$myArr = array("red", "green", "blue", "yellow");
and want to replace the last X (number of its elements) of it with the word HIDDEN
for example, if I want to replace the last 2 elements then
foreach ($myArr as $color){
echo $color . '<br />';
}
it should be like this way
red
green
HIDDEN
HIDDEN
I'm thinking about function with three arguments
function hide_elm($array, $howmany = 0, $hide_msg = 'HIDDEN'){
}
but can not handle the array to do so.