1
我試圖從每個子數組中回顯存儲在key ='Tipo'中的值。嵌套的foreach從子數組中回顯密鑰?
foreach ($palabras as $key => $palabra) {
foreach ($palabra as $key2 => $meaning) {
echo $palabra[$key2]['Tipo'];
}
}
我確定我的錯誤很簡單,但我不確定它是什麼。問題是我得到的是隨機字符,而不是隻有值。
只要你知道這是原始數組:
Array
(
[0] => Array
(
[Palabra] => juan
)
[1] => Array
(
[Palabra] => es
[0] => Array
(
[Raiz] => ser
[Tipo] => verbo1
)
[1] => Array
(
[Raiz] => ser
[Tipo] => verbo2
)
)
[2] => Array
(
[Palabra] => un
[0] => Array
(
[Tipo] => articulo-indeterminado
)
)
[3] => Array
(
[Palabra] => adjetivo
[0] => Array
(
[Tipo] => Clase
[Clase] => Adjetivo
)
)
)
而這就是我與我的代碼:
jeverbo1verbo2uarticulo-indeterminadoaClase
感謝,is_numeric修復了這些問題。改變它與給定的數組一起工作 – lisovaccaro