afficher un tableau avec du json et php

Default
,

Hello les amis devs,

Voila je rencontre un problème avec mon code, j'intéragis avec une base de donnée firebase et j'essaie d'affichier son contenue dans un tableau html rien de sorcier, j'ai réalisé un code qui fonctionne parfaitement :

 /*
 foreach ($data_users as $val) {
$reference = $database->getReference('users/'.$val);
$snapshot = $reference->getSnapshot();
$value = $snapshot->getValue();
$member_id = $snapshot->getKey();

echo "<tr><td>";
if (isset($value["name"])) {
    echo($value["name"]);
    echo "</br>";
}  else {
    echo "Non renseigné";
    echo "</br>";}
    echo "</td><td>";
if (isset($value["email"])) {
    echo($value["email"]);
    echo "</br>";
}  else {
    echo "Non renseigné";
    echo "</br>";}
    echo "</td><td>";
if (isset($value["mobileNo"])) {
    echo($value["mobileNo"]);
    echo "</br>";
}  else {
    echo "Non renseigné";
    echo "</br>";}
echo "</td><td>";
    echo($member_id);
    echo "</br>";
echo "</td></tr>";
 }
*/

le seule problème c'est que c'est extrémement gourmand en performance donc j'ai imaginé un nouveau système, je récupère toutes les valeurs dans un tableau que j'ai converti en json pour plus de lisibilité mais ce qui me perturbe c'est les array dans les array,
Je cherche donc à obtenir un code qui fonctionne comme celui présenté plus haut mais que la page charge plus rapidement

voici ce que j'optien après

print json_encode($value);

j'obtien ceci :

{"55555555":{"email":"bonjourlemonde@gmail.com","mobileNo":"0888888888","name":"Bonjour Bonjour"},"612p1cYCree05rKICm5eROjLZZS2":{"address":{"-LNAbU1UjYVAluoPSO75":{"address":"Ktw somewhere","area":"Ktw","city":"Test","mobileNo":"12979464664","name":"Ali","pincode":"12333"},"-LNAiEqdB8y5PLdPDmO3":{"address":"Shahidi Mohalla","area":"Kishtwar","city":"Kishtwar","mobileNo":"9086907906","name":"Ali Zumair","pincode":"12333"}},"favourite":{"861d3f45e98fafee4de336":{"description":"Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed in dolor pretium, finibus ligula vel, posuere leo.","thumb":"http:\/\/res.cloudinary.com\/ionicfirebaseapp\/image\/upload\/c_scale,h_400,w_564\/v1483635781\/shutterstock_309150017_mpk0xn.jpg","title":"Chicken Salad with Arugula"},"86unm0f45e98fafebbzs640":{"description":"Mauris sagittis rhoncus justo, vel bibendum nibh ultrices iaculis. Pellentesque ac facilisis mauris. Donec a tortor non ante pharetra pharetra nec ac augue. Nulla mollis lacinia est.","thumb":"http:\/\/res.cloudinary.com\/ujju\/image\/upload\/c_scale,w_709\/v1474264356\/food4_bepbym.jpg","title":"Jack Daniels"}},"loyaltyPoints":{"-LNCurn-mrQpEt0iUtPg":{"createdAt":1537831828837,"credit":true,"orderId":"-L04RzlsAKZWFREeEKk2","points":78}},"mobileNo":"0751161824"},"61566cre7RedBull":{"email":"test@test.com","name":"MrTest"},"AWmHGjGtdlZ38GJyBBt2L330bMd2":{"email":"roelof.meijer@live.nl","mobileNo":"264950269","name":"ROELOF MEIJER","role":"User"},"DBXMMGCQa9MULLgWQt0oouCZpmp2":{"address":{"-LIWtCOMIrRtxj44gr6s":{"address":"teste","area":"centro","city":"mossoro","mobileNo":"84996662713","name":"valtenci","pincode":"59614401"}},"email":"santos.rn@hotmail.com","image":"","loyaltyPoints":{"-LIWtkDW7aEzV5saWEyn":{"createdAt":1532809170510,"credit":true,"orderId":"-LIWtGDsRIpIpv6dclE3","points":31},"-LIcdGZOvdLkJ9bLk00M":{"createdAt":1532911491457,"credit":true,"orderId":"-LIcbzvzmOBF3A8hu2Ys","points":6}},"mobileNo":"84996662713","name":"valtenci","role":"User"},"DXBcNBMWSJVNtd2SS49PVLAmxdQ2":{"address":{"-LMtQ9oClCgrIU7-cU1y":{"address":"9503 Avenue B","area":"Brooklyn","city":"Brooklyn","mobileNo":"3472486302","name":"claude leveque","pincode":"11236"}},"email":"beyouu23@gmail.com","mobileNo":"+13472486305","name":"claude leveque","role":"User"},"F3zArFDF2EhyxMWE4cp039VNtoB2":{"address":{"-L9MJOfFVY12cdgu-Kd7":{"address":"101 Mai Xu\u00e2n Th\u01b0\u1edfng - V\u0129nh H\u1ea3i - Nha Trang","area":"viet nam","city":"Nha Trang","mobileNo":"1659150640","name":"Loc","pincode":"12333"}},"email":"admin@gmail.com","favourite":{"0092by642245498dd9m1":{"description":"Its Delicious","thumb":"http:\/\/res.cloudinary.com\/pietechsolutions\/image\/upload\/v1486575508\/zz7hbotx11kmlzqq0tpp.jpg","title":"Souvlaki"}},"mobileNo":"8102983777","name":"Admin","role":"Admin"},"L6Sz5iVyAORqj7tqM4rfUEb5oQN2":{"address":{"-LLZ74mOWWKbpgoHPTir":{"address":"Test Addredd","area":"Pretoria","city":"Pretoria","mobileNo":"0769108417","name":"Kalule","pincode":"0002"}},"email":"kaluledison@gmail.com","mobileNo":"0634587937","name":"kalule","role":"User"},"Me3ivlHp0UYN4rfdElIEggyJetm2":{"email":"test@test.test","mobileNo":"021321321333","name":"Test","role":"User"},"Yy5kuvWEguT9GIdvtMfSy6rrfem2":{"email":"asdasd@gmail.com","mobileNo":"adsadsasd","name":"asdasd","role":"User"},"ZUSqRxAVvcMs2NlLqrrpdMhAvnF2":{"email":"mibrahim@miinar.com","mobileNo":"1126888013","name":"Muhammad Ibrahim","role":"User"},"b9Gz5mzSl3Y4kWfGjgFI94qodAA3":{"email":"ibrahimnazeer93@hotmail.com","mobileNo":"1126888013","name":"Muhammad Ibrahim","role":"User"},"eIPPmSw4pNOIHkIPz3DgKaVI3Gj1":{"address":{"-LN70BFERF9cLxVWDgUj":{"address":"laguarda","area":"quilmes","city":"Quilmes","mobileNo":"1234567891","name":"julian martire","pincode":"1882"}},"email":"probando@probando.com","mobileNo":7777777777,"name":"probandoprobando","role":"User"},"eISXXN9QL8ThgNyUiYQf1YvJ37H2":{"email":"ibrahimnazeer93@gmail.com","mobileNo":"1126888013","name":"Muhammad Ibrahim","role":"User"},"ekQ3Bebi3hMY5PcnFpSosmrQ1Fk1":{"email":"name@gmail.com","mobileNo":"12321421","name":"name","role":"User"},"ftmnq8e2F7ZhA7HeeN1FLtxmFki1":{"email":"leonardo.falco@outlook.com","mobileNo":"17981938155","name":"Leonardo Jesus Falco","role":"User"},"h9lF345U5ue8ZUa4nPr55RWVypc2":{"email":"lesly@gmail.com","mobileNo":7776166225,"name":"lesly","role":"User"},"iY5I1uqN5vbzx8FBd2M4TlAoz0j2":{"email":"marco@byondmedia.net","mobileNo":"3057787890","name":"yolo","role":"User"},"u0S3T2V3Z0d4SAopHRENiyOYX022":{"address":{"-LFTTw4p-UaSq7Uv4lX4":{"address":"Rua corvina 266","area":"Sao carlos","city":"Itapevi","mobileNo":"950797722","name":"VITOR ALVES","pincode":"06694370"}},"email":"viitorcalvez@gmail.com","loyaltyPoints":{"-LFTU-ZD7DJS1lvquHR2":{"createdAt":1529519803731,"credit":true,"orderId":"-LFTTwylFVViY79HWyEL","points":2}},"mobileNo":"950797722","name":"Vitor Alves","role":"User"},"vTR2b0Oi63NC5gbT2oDQCQkk1Za2":{"email":"a.a.k.7500@gmail.com","mobileNo":"535314016","name":"Abdulaziz Alkharji","role":"User"},"vWhx9kifgwaxa1uxZQzDsanlbSb2":{"email":"mpro.dev8@gmail.com","image":"https:\/\/firebasestorage.googleapis.com\/v0\/b\/restaurant-1440e.appspot.com\/o\/profile%2FIMG-20180816-WA0003.jpeg?alt=media&token=e84326e8-653c-47ab-ae82-ed7acb098a9c","mobileNo":"081574185711","name":"Apa","role":"User"},"wqq0SedPOnO0mNXwG1mYTRfmZTE3":{"address":{"-LLdlLQGh9MP-GExAkHE":{"address":"17 main","area":"BTM","city":"Bengaluru","mobileNo":"9644768272","name":"Swati","pincode":"231225"}},"email":"itsswatijaiswal1@gmail.com","favourite":{"6630fb89c48d80b888c214":{"description":"Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque vitae leo vel erat dictum dignissim.","thumb":"http:\/\/res.cloudinary.com\/ionicfirebaseapp\/image\/upload\/c_scale,h_400,w_560\/v1483635603\/shutterstock_85029121_yqrjco.jpg","title":"Layered Fruits with Caramelized Biscuits"}},"mobileNo":9644768272,"name":"swati","role":"User"},"yECsdmTRj9NfKcbUXBVS5feH0y92":{"email":"vgarima577@gmail.com","image":"https:\/\/lh6.googleusercontent.com\/-VZhPo7c_eSk\/AAAAAAAAAAI\/AAAAAAAAARA\/B3jtqspOSAk\/s96-c\/photo.jpg","name":"Garima Verma","role":"User"}}

Par quel moyen je peux exploiter ses données pour obtenir le même tableau que plus haut ?
Merci de votre aide si vous pouvez m'aiguiller sur la bonne piste :)

1 Réponse

35773
,

Hello,

Je pense qu'effectivement tu pars sur la mauvaise piste... peut-tu poster le résultat de var_dump($data_users) stp ?
ATTENTION : utilise des $users de tests, pour ne pas poster des infos sensibles qui ne t'appartienne pas.