PHP 8.5.0 Released!

Voting

: one plus seven?
(Example: nine)

The Note You're Voting On

tugla
16 years ago
Beware, if you try to pad an associative array using numeric keys, your keys will be re-numbered.
<?php
$a = array('size'=>'large', 'number'=>20, 'color'=>'red');
print_r($a);
print_r(array_pad($a, 5, 'foo'));
// use timestamps as keys
$b = array(1229600459=>'large', 1229604787=>20, 1229609459=>'red');
print_r($b);
print_r(array_pad($b, 5, 'foo'));
?>

yields this:
------------------
Array
(
 [size] => large
 [number] => 20
 [color] => red
)
Array
(
 [size] => large
 [number] => 20
 [color] => red
 [0] => foo
 [1] => foo
)
Array
(
 [1229600459] => large
 [1229604787] => 20
 [1229609459] => red
)
Array
(
 [0] => large
 [1] => 20
 [2] => red
 [3] => foo
 [4] => foo
)

<< Back to user notes page

AltStyle によって変換されたページ (->オリジナル) /