Using array_pad() with associative arrays
<?php
$dogs = array('A' => 'C', 'B' => 'D', 'X' => 'Z');
$pups = array_pad($dogs, 5, 'mutt');
printf("right padding:%s", var_export($pups, TRUE));
$pups = array_pad($dogs, -5, 'mutt');
printf("left padding:%s", var_export($pups, TRUE));
printf("Dogs:%s", var_export($dogs, TRUE));
?>
Related examples in the same category