int array_unshift    ( array &$array   , mixed $value1   [, mixed $...  ] )

array_unshift() prepends passed elements to the front   of the array. Note that the list of elements is   prepended as a whole, so that the prepended elements stay in the same   order.  All numerical array keys will be modified to start counting from   zero while literal keys won't be touched.

<?php
$queue = array('a', 'b', 'c');
array_unshift($queue, 'unshift');
w($queue);
$queue = array('a', 'b', 'c');
array_unshift($queue, array('unshift','unshift_1'));
w($queue);
$queue = array('a', 'b', 'c','D'=>'dd');
array_unshift($queue, 'unshift');
w($queue);
$queue = array('a', 'b', 'c','D'=>'dd',array('unshift','unshift_1'));
array_unshift($queue, array('unshift','unshift_1'));
w($queue);
die();
D:\wamp64\www\w0827pm\study.php:109:
array (size=4)
0 => string 'unshift' (length=7)
1 => string 'a' (length=1)
2 => string 'b' (length=1)
3 => string 'c' (length=1)
D:\wamp64\www\w0827pm\study.php:109:
array (size=4)
0 =>
array (size=2)
0 => string 'unshift' (length=7)
1 => string 'unshift_1' (length=9)
1 => string 'a' (length=1)
2 => string 'b' (length=1)
3 => string 'c' (length=1)
D:\wamp64\www\w0827pm\study.php:109:
array (size=5)
0 => string 'unshift' (length=7)
1 => string 'a' (length=1)
2 => string 'b' (length=1)
3 => string 'c' (length=1)
'D' => string 'dd' (length=2)
D:\wamp64\www\w0827pm\study.php:109:
array (size=6)
0 =>
array (size=2)
0 => string 'unshift' (length=7)
1 => string 'unshift_1' (length=9)
1 => string 'a' (length=1)
2 => string 'b' (length=1)
3 => string 'c' (length=1)
'D' => string 'dd' (length=2)
4 =>
array (size=2)
0 => string 'unshift' (length=7)
1 => string 'unshift_1' (length=9)

mixed array_shift    ( array &$array   )

array_shift() shifts the first value of the    array off and returns it, shortening the    array by one element and moving everything   down. All numerical array keys will be modified to start counting from zero   while literal keys won't be touched.

 $queue = array('a', 'b', 'c');
array_shift($queue);
wb($queue);
$queue = array('a', 'b', 'c','D'=>'dd',array('shift','shift_1'));
array_shift($queue);
wb($queue);
echo '----------------------------<br>';
$queue = array('a', 'b', 'c','D'=>'dd',array('shift','shift_1'));
w($queue[count($queue)-2]);
w(current($queue));
w(next($queue));
w(next($queue));
array_shift($queue);
wb($queue); function wb($w){
w($w);
if (is_array($w)) {
w(current($w));
} else {
w('! is_array(var)');
}
}
D:\wamp64\www\w0827pm\study.php:133:
array (size=2)
0 => string 'b' (length=1)
1 => string 'c' (length=1)
D:\wamp64\www\w0827pm\study.php:133:string 'b' (length=1)
D:\wamp64\www\w0827pm\study.php:133:
array (size=4)
0 => string 'b' (length=1)
1 => string 'c' (length=1)
'D' => string 'dd' (length=2)
2 =>
array (size=2)
0 => string 'shift' (length=5)
1 => string 'shift_1' (length=7)
D:\wamp64\www\w0827pm\study.php:133:string 'b' (length=1)
----------------------------
D:\wamp64\www\w0827pm\study.php:133:
array (size=2)
0 => string 'shift' (length=5)
1 => string 'shift_1' (length=7)
D:\wamp64\www\w0827pm\study.php:133:string 'a' (length=1)
D:\wamp64\www\w0827pm\study.php:133:string 'b' (length=1)
D:\wamp64\www\w0827pm\study.php:133:string 'c' (length=1)
D:\wamp64\www\w0827pm\study.php:133:
array (size=4)
0 => string 'b' (length=1)
1 => string 'c' (length=1)
'D' => string 'dd' (length=2)
2 =>
array (size=2)
0 => string 'shift' (length=5)
1 => string 'shift_1' (length=7)
D:\wamp64\www\w0827pm\study.php:133:string 'b' (length=1)

算法提炼是落脚点-php数组-字符串函数的更多相关文章

  1. 关于ES6-{块级作用域 let const 解构赋值 数组 字符串 函数的扩展 箭头函数}

    关于ES6 块级作用域 任何一对花括号({})中的语句集都属于一个块,在块中声明的变量在代码块外都是不可访问的,称之为块级作用域,ES5以前没有块级作用域 let let 是ES6新增的声明变量的一种 ...

  2. PHP函数积累总结(Math函数、字符串函数、数组函数)

    Math函数:10个较常用标红.abs — 绝对值acos — 反余弦acosh — 反双曲余弦asin — 反正弦asinh — 反双曲正弦atan2 — 两个参数的反正切atan — 反正切ata ...

  3. PHP 函数(数组字符串)

    函数四要素:  参数  变量   返回值  函数体 函数分类: 1.有参数的函数: function Show() { echo "hello"; } Show(); 2. 有返回 ...

  4. javascript函数一共可分为五类: ·常规函数 ·数组函数 ·日期函数 ·数学函数 ·字符串函数

    javascript函数一共可分为五类:    ·常规函数    ·数组函数    ·日期函数    ·数学函数    ·字符串函数    1.常规函数    javascript常规函数包括以下9个 ...

  5. php随机数、时间、字符串函数,正则,数组函数

    <?php//1.随机数和时间//echo rand(); //随机数生成器//echo rand(0,10); //生成某个范围内的随机数 //echo time(); //取当前时间戳//e ...

  6. ***php解析JSON二维数组字符串(json_decode函数第二个参数True和False的区别)

    客户端的请求体中的数据:[{"msg_id": 1, "msg_status": "HAS_READ" }, { "msg_id& ...

  7. js数组,字符串,json互相转换函数有哪些

    js数组,字符串,json互相转换函数有哪些 一.总结 一句话总结: JSON.stringify(arr) JSON.parse(jsonString) str.split('') array.jo ...

  8. Js中常用的字符串,数组,函数扩展

    由于最近辞职在家,自己的时间相对多一点.所以就根据prototytpeJS的API,结合自己正在看的司徒大神的<javascript框架设计>,整理了下Js中常用一些字符串,数组,函数扩展 ...

  9. js数组,数字函数,字符串函数,表单验证,hashMap,堆栈,日期函数,call函数

    1.javascript的数组API Js代码 收藏代码 //定义数组 var pageIds = new Array(); pageIds.push('A'); 数组长度 pageIds.lengt ...

随机推荐

  1. vuejs监听苹果iphone手机键盘事件

    在iphone手机中,vue提供的keyup事件是不能监听iphone键盘的,但是h5提供的input事件可以做到. 只需要向下面这样处理,就可以解决iphone不响应键盘事件的bug <tem ...

  2. PHP代码执行函数总结

    PHP中可以执行代码的函数,常用于编写一句话木马,可能导致代码执行漏洞,这里对代码执行函数做一些归纳. 常见代码执行函数,如 eval().assert().preg_replace().create ...

  3. 【RF库Collections测试】Keep In Dictionary

    Name:Keep In DictionarySource:Collections <test library>Arguments:[ dictionary | *keys ]Keeps ...

  4. 设置开机自启动VirtualBox虚拟机系统

    如果常用VirtualBox虚拟机系统的话,设置个随开机启动也是很方便的.不需要打开VirtualBox窗口,直接就是系统启动了. 又继续上网搜索学习了.(设置开机自启动VirtualBox虚拟机系统 ...

  5. SaltStack salt-run 命令

    salt-run 常见用法如下: salt-run manage.up # 查看在线的minion salt-run manage.down # 查看不在线的minion salt-run manag ...

  6. 使用Html和ashx文件实现其简单的注册页面

    记得上一次博客中实现的是其登录页面,其实学会了登录页面,注册页面自然就知道怎么写啦,都是一个意思的,但是今天不知道怎么个情况,写一个注册页面程序 中 一直在出错,大的问题小的问题一直出错,似乎是不在状 ...

  7. centos7/nginx/tornado错误异常收集

    临时方法 – 设置系统参数 使用命令setenforce 附: setenforce 设置SELinux 成为enforcing模式 setenforce 设置SELinux 成为permissive ...

  8. redis基本结构

    redis数据结构string(字符串)1->12->23->3 list(列表)key->(1->2->3->4->5) hash(散列)1-> ...

  9. 《征服C指针》读书笔记

    本文同时发布在我的个人博客上,欢迎访问~ www.seekingdream.cn 在读完K&R之后,对C的认识就是指针.数组.网上的人们对指针也有些“敬而远之”的感觉.最近从同学处淘得< ...

  10. java(6) ArrayList源码

    系统环境: JDK 1.7 成员变量 //默认的初始化数组大小 private static final int DEFAULT_CAPACITY = 10; //空的对象数组 private sta ...