1

我需要帮助来访问所有字段中的数据,原始数据从 json 对象提供并且已经在数组 $from 中解码

这是一个 print_r($from) 结果:

Array ( [0] => Array ([numberOfResult] => 1 [idUsager] => 1 [idUnique] => 1880e784 [codeLanguage] => fr [language] => Français [idCountry] => 66 [country] => Québec - Montréal [photo] => /usagers/1/1880e784/1880e784.png [pseudo] => PLATiNUM2727 [firstName] => Bedard [lastName] => Gabriel [ddn] => 1994-08-19 [mindText] => new status [compteVerifie] => 2012-01-03 [online] => 10 [onlineDescription] => En ligne [iSearch] => 3 [iSearchDescription] => Amis [level] => 5000 [levelDescription] => Administrateur [lookingFor] => partys & événements, Sexe, Autre..., [myInterest] => nature [myFavoriteBooks] => Dan Brown [myFavoriteMovies] => action [myFavoriteMusic] => Trance4Ever [myFavoriteTvShows] => CSI Miami [description] => description [dateDescrWaitingApproval] => 2012-07-17 17:38:23 [dateDescrApprouved] => 0000-00-00 00:00:00 [descriptionWaiting] => test [lastModification] => 2012-10-06 20:51:59 [bodyType] => Costaud [carOwner] => Non [homeOwner] => Non [smoking] => Non [drinking] => Socialement [drug] => Rarement [eyeColor] => Brun pâle [hairColor] => Bruns pâles [education] => BACC Universitaire gradué [height] => 5'7" (170 cm) [weight] => 196 lbs (89 kg) [relationshipStatus] => Célibataire [sexualOrientation] => Préfère ne pas dire [zodiac] => Capricorne [job] => Informatique ) )`

例如,我如何访问 [numberOfResult] 或 [firstName] ?

4

3 回答 3

2
$from[0]['numberOfResult']

                                 

于 2012-10-13T04:14:04.020 回答
1

这是二维数组的示例表,

在此处输入图像描述

在 PHP 到 HTML 中访问和显示上表的代码。

<?php
echo "<h1>Manual access to each element</h1>";

echo $shop[0][0]." costs ".$shop[0][2]." and you get ".$shop[0][2]."<br />";
echo $shop[1][0]." costs ".$shop[1][3]." and you get ".$shop[1][2]."<br />";
echo $shop[2][0]." costs ".$shop[2][4]." and you get ".$shop[2][2]."<br />";

echo "<h1>Using loops to display array elements</h1>";

echo "<ol>";
for ($row = 0; $row < 3; $row++)
{
    echo "<li><b>The row number $row</b>";
    echo "<ul>";

    for ($col = 0; $col < 3; $col++)
    {
        echo "<li>".$shop[$row][$col]."</li>";
    }

    echo "</ul>";
    echo "</li>";
}
echo "</ol>";
?>

参考链接

我希望这能帮到您。谢谢。

于 2012-10-13T04:20:22.110 回答
0

[numberOfResult]这个

echo $from[0]['numberOfResult'];

[firstName]使用它

echo $from[0]['firstName'];
于 2012-10-13T04:14:58.213 回答