ああ、解決してなかったんですね
たとえばこう
PHP
1<?PHP
2$fp=fopen("myfile.txt","r");
3while(($data=fgetcsv($fp,1024))!==false){
4 $tmp=[];
5 array_walk($data,function($x) use(&$tmp){
6 $y=explode("=",$x);
7 $tmp[trim($y[0])]=trim($y[1]);
8 });
9 $datas[]=$tmp;
10}
11fclose($fp);
12print json_encode($datas,JSON_UNESCAPED_UNICODE);
冗長に書くとこんな感じ
PHP
1$fp=fopen("myfile.txt","r");
2while(($data=fgetcsv($fp,1024))!==false){
3 $tmp=&$datas[];
4 foreach($data as $x){
5 $y=explode("=",$x);
6 $tmp[trim($y[0])]=trim($y[1]);
7 }
8}
9unset($tmp);
10fclose($fp);
11print json_encode($datas,JSON_UNESCAPED_UNICODE);
json
1[{"名前":"ハンバーグ","分類":"洋食","主成分":"タンパク質"},{"名前":"寿司","分類":"和食","主成分":"炭水化物"},{"名前":"牛乳","分類":"飲み物","主成分":"カルシウム"}]