Array function library: Array_pad

Source: Internet
Author: User
Keywords array_pad php Chinese function manual array function library
Tags aliyun array array function library array_pad function function library html http

Array_pad

(PHP4 >= 4.0b4)

Array_pad---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Packing array for specified length and value

Syntax: array array_pad (array input, int pad_size, mixed pad_value);

Description:

This function fills array arrays with arrays of size pad_size and value pad_value, and returns the padded array, if the argument pad_size is a positive number, padding to the right of the array and, if negative, padding to the left of the array. If the absolute value of the parameter pad_size is less than or equal to the length of the array input, it will not be padded.

Example:

<?php

$input = Array (12, 10, 9);

$result = Array_pad ($input, 5, 0);

Result is Array (12, 10, 9, 0, 0)

$result = Array_pad ($input,-7,-1);

Result is array (-1,-1,-1,-1, 12, 10, 9)

$result = Array_pad ($input, 2, "NoOp");

Not padded

?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.