douhuiyan2772 2014-11-12 19:37
浏览 30

无法像我想要的那样输出数组(PHP)数组输出操作

Hello I have to create the following Array

{{x: 140224, y: 50.1},{x: 140225, y: 50.0},{x: 140226, y: 50.0},{x: 140227, y: 50.0},{x: 140228, y: 50.1},{x: 140229, y: 50.0},{x: 140230, y: 50.0},{x: 140231, y: 50.0},{x: 140232, y: 50.0},{x: 140233, y: 50.0},{x: 140234, y: 50.0},{x: 140235, y: 50.0},{x: 140236, y: 50.0},{x: 140237, y: 50.0},{x: 140238, y: 50.0},{x: 140239, y: 50.0},{x: 140240, y: 50.0},{x: 140241, y: 50.0},{x: 140242, y: 50.0},{x: 140243, y: 50.0},{x: 140244, y: 50.0}}

without the first { element[0] and the last } so it should look like this

{x: 140224, y: 50.1},{x: 140225, y: 50.0},{x: 140226, y: 50.0},{x: 140227, y: 50.0},{x: 140228, y: 50.1},{x: 140229, y: 50.0},{x: 140230, y: 50.0},{x: 140231, y: 50.0},{x: 140232, y: 50.0},{x: 140233, y: 50.0},{x: 140234, y: 50.0},{x: 140235, y: 50.0},{x: 140236, y: 50.0},{x: 140237, y: 50.0},{x: 140238, y: 50.0},{x: 140239, y: 50.0},{x: 140240, y: 50.0},{x: 140241, y: 50.0},{x: 140242, y: 50.0},{x: 140243, y: 50.0},{x: 140244, y: 50.0}

The code I have to produce this string:

 $arraytime[] = array('x: ' . $measurement[2] . ', y: ' . $measurement[12]);

$js_arraytime = json_encode($arraytime);
$js_arraytime = str_replace('"', '' ,$js_arraytime);//
$js_arraytime = str_replace("[", '{', $js_arraytime);
$js_arraytime = str_replace("]", '}', $js_arraytime); 

echo $js_arraytime;

if i try to replace $js_arraytime[0] with something else every first element of an array is changing. Can someone please help me out

  • 写回答

3条回答 默认 最新

  • duanan1228 2014-11-12 19:44
    关注

    how about this substr($js_arraytime, 1,-1);

    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序