dongshuo2752 2017-03-06 08:27
浏览 19

PHP foreach获取stripslashes()需要参数1

array(1) {
  [0]=>
  array(11) {
    ["deductionspayment"]=>
    array(3) {
      [0]=>
      array(3) {
        ["amount"]=>
        string(4) "1.03"
        ["year"]=>
        string(4) "2017"
        ["month"]=>
        string(5) "March"
      }
      [1]=>
      array(3) {
        ["amount"]=>
        string(4) "1.03"
        ["year"]=>
        string(4) "2017"
        ["month"]=>
        string(5) "April"
      }
      [2]=>
      array(3) {
        ["amount"]=>
        string(4) "1.03"
        ["year"]=>
        string(4) "2017"
        ["month"]=>
        string(3) "May"
      }
    }
    ["deductionsname"]=>
    string(3) "SSS"
    ["deductionstart"]=>
    string(10) "2017-03-08"
    ["deductionsend"]=>
    string(10) "2017-03-14"
    ["deductionsamount"]=>
    string(4) "3.09"
    ["deductionsyears"]=>
    string(1) "3"
    ["deductionsdate"]=>
    string(10) "2017-03-18"
    ["deductionschedule"]=>
    string(1) "3"
    ["deductionstype"]=>
    string(1) "1"
    ["deductionsprincipalamount"]=>
    string(1) "3"
    ["deductionsinterest"]=>
    string(1) "3"
  }
}
<br />
<b>Warning</b>:  stripslashes() expects parameter 1 to be string, array given in 
<b>Warning</b>:  Invalid argument supplied for foreach() in 
{"error":false,"message":"Update Successful.!"}

This is my var_dump of my $jsondeduction and I am using this in foreach like

foreach ($jsondeduction as $val) {
                $jsondeductionspayments = json_decode(stripslashes($val['deductionspayment']), true);

But i am getting error and i am assuming that the error is coming from this line : $jsondeductionspayments = json_decode(stripslashes($val['deductionspayment']), true);

How should I format this data to allow stripslashes

  • 写回答

4条回答 默认 最新

  • doukang7858 2017-03-06 08:35
    关注

    stripslashes :

    stripslashes — Un-quotes a quoted string

    string stripslashes ( string $str )
    

    stripslashes expects a string parameter while you are sending an array $val['deductionspayment'] which is not a string variable

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用