PHP和JavaScrip分别获取关联数组的键值示例代码_php技巧_脚本之家

2020-01-24 23:18栏目:编程
TAG:

PHP版: 复制代码 代码如下: $o = array('x'=>1, 'y'=>2, 'z'=>3); $arr = array(); $i = 0; foreach( $o as $arr[$i++]=>$v )/*empty*/; var_dump; //$arr = array; JavaScrip版: 复制代码 代码如下: var o = {x:1, y:2, z:3}; var arr = [], i = 0; for /*empty*/ ; console.log; //arr = ['x', 'y', 'z'];

//$str1 = explode;
//echo implode("&",$str1);

$arr2 = array(
'x' => 'a',
'y' => 'b',
'z' => 'c',
9 => 35
);
//$arr_merge=array_merge($arr,$arr2);
//var_dump($arr_merge);
//echo $arr2[2];
//var_dump;
//array_push($arr2,'xxx');
//var_dump;
//var_dump(in_array('v',$arr2));
//$arr_reverse = array_reverse;
//var_dump($arr_reverse);
//unset;
//$ar2 = null;
//var_dump;
//for($i=0;$i<count;$i++)
//{
//
//}
foreach ($arr2 as $k)
{
var_dump;
}
foreach ($arr2 as $k=>$v){
var_dump($arr2[$k]);
}
//echo $v;

<?php
//生成随机数 和 时间函数
//echo rand();
//echo "<br>";
//echo rand;
//echo time();//时间戳
//2017-02-10 08:46:12
date_default_timezone_set("Asia/Shanghai");

//$str = "a|B|c|d";

版权声明:本文由bob体育app发布于编程,转载请注明出处:PHP和JavaScrip分别获取关联数组的键值示例代码_php技巧_脚本之家