アドバイスを求める: データ形式に関する質問
データ ソース形式:
<br />
$data = array(<br />
array('id' => 1,'pid' => 0,'name' => 'a'),<br />
array('id' => 2,'pid' => 0,'name' => 'b'),<br />
array('id' => 3,'pid' => 1,'name' => 'c'),<br />
array('id' => 4,'pid' => 1,'name' => 'd'),<br />
array('id' => 5,'pid' => 3,'name' => 'e'),<br />
array('id' => 6,'pid' => 3,'name' => 'f'),<br />
array('id' => 7,'pid' => 6,'name' => 'g'),<br />
array('id' => 8,'pid' => 6,'name' => 'h'),<br />
array('id' => 9,'pid' => 8,'name' => 'i'),<br />
array('id' => 10,'pid' => 8,'name' => 'j'),<br />
array('id' => 11,'pid' => 9,'name' => 'l'),<br />
array('id' => 12,'pid' => 9,'name' => 'm'),<br />
);<br />
ログイン後にコピー
データ形式は次の形式である必要があります:
配列(
'a' => 配列(
'c' => 'c',
'd' => 配列(
'e' => 'e',
'f' => 配列(
'g' =>
'h' => 配列(
'i' =>
'l' => 'l',
'm' =>
)、
'j' =>
)、
)
)
)、
'b' => 'b'
)
私を助けてください
-----解決策---------
$data = array(
array('id' => 1,'pid' => 0,'name' => 'a'),
array('id' => 2,'pid' => 0,'name' => 'b'),
array('id' => 3,'pid' => 1,'name' => 'c'),
array('id' => 4,'pid' => 1,'name' => 'd'),
array('id' => 5,'pid' => 3,'name' => 'e'),
array('id' => 6,'pid' => 3,'name' => 'f'),
array('id' => 7,'pid' => 6,'name' => 'g'),
array('id' => 8,'pid' => 6,'name' => 'h'),
array('id' => 9,'pid' => 8,'name' => 'i'),
array('id' => 10,'pid' => 8,'name' => 'j'),
array('id' => 11,'pid' => 9,'name' => 'l'),
array('id' => 12,'pid' => 9,'name' => 'm'),
);
/********私はYDの境界線*************/
$pid = 1000000;
//$mark = 'c';
foreach ($data as $key => $value){
if ($value[pid] == $pid) {