build multidimensional array from string php

前端 未结 4 1473
我在风中等你
我在风中等你 2021-01-03 13:20

EDIT: Here is a portion of $preparedstring:

555555,Jones,Brian,NYC,1000,2011-10-21 00:00:00,Check,1542,0, ,Check, ,0, ,Check, ,; 666666

4条回答
  •  有刺的猬
    2021-01-03 13:59

    You're close, but arrays don't work that way. You can't put a foreach inside an array constructor like that. It should look like this:

    $outerARR = explode(";", $preparedstring);
    $arr = array();
    foreach ($outerARR as $arrvalue){
       $innerarr = explode(",", $arrvalue);
       $arr[] = $innerarr;
    }
    

    Demo: http://codepad.org/I5wFFczR

提交回复
热议问题