算法提炼是落脚点-php数组-字符串函数
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数组-字符串函数的更多相关文章
- 关于ES6-{块级作用域 let const 解构赋值  数组 字符串 函数的扩展 箭头函数}
		
关于ES6 块级作用域 任何一对花括号({})中的语句集都属于一个块,在块中声明的变量在代码块外都是不可访问的,称之为块级作用域,ES5以前没有块级作用域 let let 是ES6新增的声明变量的一种 ...
 - PHP函数积累总结(Math函数、字符串函数、数组函数)
		
Math函数:10个较常用标红.abs — 绝对值acos — 反余弦acosh — 反双曲余弦asin — 反正弦asinh — 反双曲正弦atan2 — 两个参数的反正切atan — 反正切ata ...
 - PHP 函数(数组字符串)
		
函数四要素: 参数 变量 返回值 函数体 函数分类: 1.有参数的函数: function Show() { echo "hello"; } Show(); 2. 有返回 ...
 - javascript函数一共可分为五类:    ·常规函数    ·数组函数    ·日期函数    ·数学函数    ·字符串函数
		
javascript函数一共可分为五类: ·常规函数 ·数组函数 ·日期函数 ·数学函数 ·字符串函数 1.常规函数 javascript常规函数包括以下9个 ...
 - php随机数、时间、字符串函数,正则,数组函数
		
<?php//1.随机数和时间//echo rand(); //随机数生成器//echo rand(0,10); //生成某个范围内的随机数 //echo time(); //取当前时间戳//e ...
 - ***php解析JSON二维数组字符串(json_decode函数第二个参数True和False的区别)
		
客户端的请求体中的数据:[{"msg_id": 1, "msg_status": "HAS_READ" }, { "msg_id& ...
 - js数组,字符串,json互相转换函数有哪些
		
js数组,字符串,json互相转换函数有哪些 一.总结 一句话总结: JSON.stringify(arr) JSON.parse(jsonString) str.split('') array.jo ...
 - Js中常用的字符串,数组,函数扩展
		
由于最近辞职在家,自己的时间相对多一点.所以就根据prototytpeJS的API,结合自己正在看的司徒大神的<javascript框架设计>,整理了下Js中常用一些字符串,数组,函数扩展 ...
 - js数组,数字函数,字符串函数,表单验证,hashMap,堆栈,日期函数,call函数
		
1.javascript的数组API Js代码 收藏代码 //定义数组 var pageIds = new Array(); pageIds.push('A'); 数组长度 pageIds.lengt ...
 
随机推荐
- Python爬虫学习笔记-2.Requests库
			
Requests是Python的一个优雅而简单的HTTP库,它比Pyhton内置的urllib库,更加强大. 0X01 基本使用 安装 Requests,只要在你的终端中运行这个简单命令即可: pip ...
 - RF-字符串转为整数的方法
 - 如何在LSI MegaRAID BIOS里设定RAID 10与Hot Spare
			
1. 同时按下 ”Ctrl + H” 进入MegaRAID WebBIOS 画面,可以看到所有物理硬盘 (Physical Drives) 的信息.请在左边视窗点选“Configuration Wiz ...
 - SpringBoot(一)-- 知识点介绍
			
一.简介 Spring Boot是为了简化Spring应用的创建.运行.调试.部署等而出现的,使用它可以做到专注于Spring应用的开发,而无需过多关注XML的配置.简单来说,它提供了一堆依赖打包,并 ...
 - 最短路径——Dijkstra算法和Floyd算法
			
Dijkstra算法概述 Dijkstra算法是由荷兰计算机科学家狄克斯特拉(Dijkstra)于1959 年提出的,因此又叫狄克斯特拉算法.是从一个顶点到其余各顶点的最短路径算法,解决的是有向图(无 ...
 - 使用composer进行依赖管理:以guzzle为例
			
今天突然发现一个不错的php http客户端库guzzle,欣喜不已,跃跃欲试.打开guzzle文档,发现需要composer做依赖管理.之前没有接触过composer,正好以此学习下,也蛮好! 本文 ...
 - 随心所欲玩复制 详解robocopy
			
说实话,Windows系统自带的复制功能不仅功能简单,而且定制性也不强,每每在对大量文件进行复制.移动.备份时,总少不了繁杂往复的操作.不过幸好,微软意识到了这一点,为我们提供了一款很强力的复制备份工 ...
 - Intellij 部署项目java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
			
报错信息: org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener ...
 - Elasticsearch学习之多种查询方式
			
1. query string search 搜索全部商品:GET /ecommerce/product/_search took:耗费了几毫秒 timed_out:是否超时,这里是没有 _shard ...
 - 第四步 使用 adt-eclipse 打包 Cordova (3.0及其以上版本) + sencha touch 项目
			
cordova最新中文api http://cordova.apache.org/docs/zh/3.1.0/ 1.将Cordova 生成的项目导入到adt-eclipse中,如下: 项目结构如下: ...