按序列类型:

<?php
header('Content-type:application/json;charset=utf-8');
  // 索引数组
  $i= array("hexingxing","24","male",["music","UX/UE","game"],"hexingxing.cn","it@hexingxing.cn");
  echo json_encode($i, JSON_FORCE_OBJECT);
?>

打印结果:

{"0":"hexingxing","1":"24","2":"male","3":{"0":"music","1":"UX\/UE","2":"game"},"4":"hexingxing.cn","5":"it@hexingxing.cn"}

调用数据:

{略}

指定 ID 类型:

<?php
header('Content-type:application/json;charset=utf-8');
  // 索引数组
  $i= array('nane'=>'hexingxing','age'=>'24','gender'=>'male','like'=>['music','UX/UE','game'],'web'=>'hexingxing.cn','email'=>'it@hexingxing.cn');
  echo json_encode($i, JSON_FORCE_OBJECT);
?>

打印结果:

{"nane":"hexingxing","age":"24","gender":"male","like":{"0":"music","1":"UX\/UE","2":"game"},"web":"hexingxing.cn","email":"it@hexingxing.cn"}

调用数据:

{略}


何星星原创文章仅用于个人学习,当前页面暂不支持复制操作,了解详情或文章转载请 点此 继续!
分类: 前端开发

0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用*标注