InterviewSolution
| 1. |
How To Pad An Array With The Same Value Multiple Times? |
|
Answer» If you want to add the same value multiple times to the end or beginning of an array, you can use the array_pad($array, $new_size, $value) FUNCTION. If the second argument, $new_size, is POSITIVE, it will pad to the end of the array. If negative, it will pad to the beginning of the array. If the absolute value of $new_size if not greater than the current size of the array, no PADDING takes place. Here is a PHP script on how to use array_pad(): If you want to add the same value multiple times to the end or beginning of an array, you can use the array_pad($array, $new_size, $value) function. If the second argument, $new_size, is positive, it will pad to the end of the array. If negative, it will pad to the beginning of the array. If the absolute value of $new_size if not greater than the current size of the array, no padding takes place. Here is a PHP script on how to use array_pad(): |
|