我試圖從數組中獲取數據,包括DetectedText值和BoundingBox所有四個值。但面臨問題。完整的數據在'$prepared_arr'中,給定數組的結構如下。print_r ($prepared_arr);// variable having complete dataArray //output of above array used in pipeline([0] => Array ( [DetectedText] => The number of goals [BoundingBox] => Array ( [Width] => 0.66954100131989 [Top] => 0.04796177148819 [Left] => 0.2710283100605 [Height] => 0.072451308369637 ) )[1] => Array ( [DetectedText] => in world cup match [BoundingBox] => Array ( [Width] => 0.33683118224144 [Top] => 0.12350185215473 [Left] => 0.12564577162266 [Height] => 0.066131837666035 ) ))如果我使用 print_r ($prepared_arr[1]) 它只返回索引 1 的完整數據。先感謝您
3 回答

寶慕林4294392
TA貢獻2021條經驗 獲得超8個贊
您可以使用foreach從數組中獲取數據,例如:
// with your example
foreach($prepared_arr as $val)
{
echo "DetectedText: ". $val['DetectedText']."<br/>"; // using br for line break
foreach ($val['BoundingBox'] as $key => $valueInner) {
echo $key.": ".$valueInner."<br/>"; // using br for line break
}
}
- 3 回答
- 0 關注
- 207 瀏覽
添加回答
舉報
0/150
提交
取消