My code:
$a = array_fill(5, 6, 'banana');
prints
Array
(
[5] => banana
[6] => banana
[7] => banana
[8] => banana
[9] => banana
[10] => banana
)
But I wanted it something like below
Array
(
[5] => banana 1
[6] => banana 2
[7] => banana 3
[8] => banana 4
[9] => banana 5
[10] => banana 6
)
Is there any other php function there to achieve above? If yes, could you please let me know.
function test_print_value($item2, $key, $some_value)
{
echo $some_value." $item2<br />\n";
}
array_walk(range(0,10), 'test_print_value', 'Banana Apple ');
Output:
Banana Apple 0
Banana Apple 1
Banana Apple 2
Banana Apple 3
Banana Apple 4
Banana Apple 5
Banana Apple 6
Banana Apple 7
Banana Apple 8
Banana Apple 9
Banana Apple 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With