索引数组

<?php
//json_encode(数组/对象)
$color = array('red','blue','green');
echo json_encode($color); //["red","blue","green"]
?>

关联数组

<?php
$animal = array('east'=>'tiger','north'=>'wolf','south'=>'monkey');
echo json_encode($animal); //{"east":"tiger","north":"wolf","south":"monkey"}
?>

json数组

<?php
$file_arr = array();//保存文件名
$dir = dir("D:\\input");//目录
while($file = $dir->read()){//循环目录
global $file_arr; //全局
if($file !=".." && $file !="."){//判断不为返回上级
$file_arr[] = $file;
}
}
echo json_encode($file_arr); //["1.png","2.png"]
?>

json关联数组

<?php
$animal = array();
$animal['east'] = "tiger";
$animal['north'] = "wolf";
echo json_encode($animal); //{"east":"tiger","north":"wolf"}
?>

最新文章

  1. [Erlang 0123] Erlang EPMD
  2. Java集合之LinkedList
  3. C语言调用curl库抓取网页图片(转)
  4. KVM 介绍(7):使用 libvirt 做 QEMU/KVM 快照和 Nova 实例的快照 (Nova Instances Snapshot Libvirt)
  5. js常用正则表达式汇总
  6. Visual Studio 2015 Update 3 RC 候选预览版粗来了
  7. snowflake主键生成策略
  8. calling c++ from golang with swig--windows dll (三)
  9. pymysql的使用及sql注入
  10. Hibernate Search集与lucene分词查询
  11. JavaScrip 入门第一课
  12. nuxt框架Universal和Spa两种render mode的区别
  13. ES5-ES6-ES7_async函数
  14. str类型
  15. 评定星级的前端显示js
  16. async语法升级踩坑小记
  17. linux上传下载文件rz,sz
  18. Gogland使用 - 非常简单查看Go语言源代码全貌!
  19. 20165218 2017-2018-2 《Java程序设计》课程总结
  20. Ionic开发Hybrid App问题总结

热门文章

  1. Spring data redis的使用
  2. USACO Balanced Lineup
  3. 两个开源的 Spring Boot + Vue 前后端分离项目
  4. 编译安装php-fpm5.6 (centos 7)
  5. 认识map-reduce
  6. C#面试题(一)
  7. nodejs调用cmd命令
  8. 动手学深度学习1- pytorch初学
  9. AbstractExecutorService源码
  10. Prometheus 一条告警的触发流程、等待时间