search

Home  >  Q&A  >  body text

php如何构造数组

$arr = array(
foreach ($list->list as $json) {
"file"=>str_replace('99552', '', $json->path)
}
);

我这样写提示Parse error: syntax error, unexpected T_FOREACH, expecting ')',该如何修改?

ringa_leeringa_lee2829 days ago573

reply all(3)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-10 17:29:52

    $arr = array(); 
    foreach ($list->list as $json) 
    {
    $arr[] = array(
    "file"=>str_replace('99552', '', $json->path);
    ); 
    }

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-10 17:29:52

    $arr = array(); 
    foreach ($list->list as $json) 
    {
        $arr[] = str_replace('99552', '', $json->path);
    }
    var_dump($arr);

    即可。

    reply
    0
  • 迷茫

    迷茫2017-04-10 17:29:52

    新手路过学习一下,感谢bio.soyiyuan.com

    reply
    0
  • Cancelreply