PHP array_pad()函数与示例
PHP array_pad()函数 (PHP array_pad() function)
array_pad() function is used to pad an array to given size with a specified value and returns a new array with a specified value.
array_pad()函数用于将数组填充到具有指定值的给定大小,并返回具有指定值的新数组。
Syntax:
句法:
array_pad(array, size, value);
Here,
这里,
array is an array in which we have to add the elements.
数组是我们必须在其中添加元素的数组。
size is the length/size of the array.
size是数组的长度/大小。
value is the value to be added to pad an array.
value是要填充数组的值。
Examples:
例子:
Input:
$arr = array(10, 20, 30);
Function call:
array_pad($arr, 5, 100);
Output:
Array
(
[0] => 10
[1] => 20
[2] => 30
[3] => 100
[4] => 100
)
PHP code:
PHP代码:
<?php
$arr = array(10, 20, 30);
//padding to 5 elements with value 100
$result = array_pad($arr, 5, 100);
//printing
print_r ($result);
$arr = array("Hello", "Guys");
//padding to 5 elements with value "Bye!"
$result = array_pad($arr, 5, "Bye!");
//printing
print_r ($result);
?>
Output
输出量
Array
(
[0] => 10
[1] => 20
[2] => 30
[3] => 100
[4] => 100
)
Array
(
[0] => Hello
[1] => Guys
[2] => Bye!
[3] => Bye!
[4] => Bye!
)
翻译自: https://www.includehelp.com/php/array_pad-function-with-example.aspx
PHP array_pad()函数与示例相关推荐
- php指定长度 分割整形,php指定长度分割字符串str_split函数用法示例
本文实例讲述了php指定长度分割字符串str_split函数用法.分享给大家供大家参考,具体如下: 示例1:$str = 'abcdefgh'; $arr = str_split($str,2); 运 ...
- getdate函数_PHP getdate()函数与示例
getdate函数 PHP getdate()函数 (PHP getdate() function) getdate() function is used to get the local date/ ...
- 安卓log.e函数打印示例_log1p()函数以及C ++中的示例
安卓log.e函数打印示例 C ++ log1p()函数 (C++ log1p() function) log1p() function is a library function of cmath ...
- gettimeofday_PHP gettimeofday()函数与示例
gettimeofday PHP gettimeofday()函数 (PHP gettimeofday() function) gettimeofday() function is used to g ...
- dir函数_PHP dir()函数与示例
dir函数 PHP dir()函数 (PHP dir() function) dir() function is an instance of the directory class, it is u ...
- PHP rewinddir()函数与示例
PHP rewinddir()函数 (PHP rewinddir() function) rewinddir() function is used to rewind/reset the direct ...
- stl swap函数_C ++ STL | vector :: swap()函数与示例
stl swap函数 C ++ STL vector :: swap()函数 (C++ STL vector::swap() function) vector::swap() function is ...
- C#回调函数应用示例,形象比喻方法助理解
C#回调函数应用示例,形象比喻方法助理解,整理了一个简单的例子来说明回调函数的用法: namespace CallBackFunction { class Program { ...
- php解escape,PHP下escape解码函数用法示例
这篇文章主要为大家详细介绍了PHP下escape解码函数用法示例,具有一定的参考价值,可以用来参考一下. 感兴趣的小伙伴,下面一起跟随512笔记的小编小韵来看看吧!GB2312编码: 代码如下: fu ...
最新文章
- 【UML 建模】UML建模语言入门 -- 用例视图详解 用例视图建模实战
- 实现简约不简单的vuex
- 郊游 ID:PICNIC
- python查看CNN训练模型参数
- mysql4函数,mysql笔记4_函数_MySQL
- UPX 加壳工具:The Ultimate Packer for eXecutables
- 精华阅读第6期|程序猿的世界,你不懂!
- Linux命令 umask,chmod使用
- ajax 表格删除,jQuery AJAX删除只捕获第一个表格
- ensp综合组网实验_关于实验室温度控制的那些事
- 使用to like动词_17
- Proteus安装图文教程
- 2022低压电工判断题及在线模拟考试
- 如何寻找logo创意灵感?推荐这8个设计灵感网站
- 概率论与数理统计,基础知识、公式、定理、概念(一)
- python-百分号字符串拼接
- Eclipse12:CookieSession
- 5G QoS控制原理专题详解-基础概念(3)
- 2018最新苹果公司开发者账号设置税务
- IFPUG软件功能点计算方法
热门文章
- 深度linux内核升级,深度操作系统 2020.11.11 更新发布:内核升级
- php 安全mysql,关于php:我从mysql注入安全吗?
- centos7配置br0_Docker CentOS7 修改网络配置与宿主机桥接
- 高性能MySQL(4)——查询性能优化
- shell 整数条件判断
- linuxSAMBA共享
- ie6 javascript js 缺少标识符总结(转载)
- 检测Java对象所占内存大小 (转载)
- rhel5之光盘更新终结篇
- 多核分布式队列的实现:“偷”与“自私”的运用(1)