Jump to content
Lucas Regis

trabalhando com .json com vários Objetos

Recommended Posts

Estou tendo bastante dificuldades em pegar dados em um arquivo .json, ele possui vários objetos e quando uso o foreach() para percorre-lo.

 

Poe exemplo, segue o .json

{"card-header":{"raceId":"1706057","races":{"95049":{"meeting_abandoned":0,"track":"Kilkenny","races":[{"raceId":"1706057","raceDate":"2019-07-03","raceTime":"8:12"},{"raceId":"1706058","raceDate":"2019-07-03","raceTime":"8:27"},{"raceId":"1706059","raceDate":"2019-07-03","raceTime":"8:43"},{"raceId":"1706060","raceDate":"2019-07-03","raceTime":"9:02"},{"raceId":"1706857","raceDate":"2019-07-03","raceTime":"9:18"},{"raceId":"1706858","raceDate":"2019-07-03","raceTime":"9:34"},{"raceId":"1706859","raceDate":"2019-07-03","raceTime":"9:52"},{"raceId":"1706860","raceDate":"2019-07-03","raceTime":"10:07"},{"raceId":"1706861","raceDate":"2019-07-03","raceTime":"10:23"},{"raceId":"1706862","raceDate":"2019-07-03","raceTime":"10:41"}],"track_id":"50","tv_id":"","tv_name":""}},"courseId":95049,"country":"IRE","trackAbbrName":"K'kenny"},"card-title":{"postPick":"6-5-3","napNum":"","raceSisStatusTopicD5":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/#SIS_STATUS","infoTopicD5":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/OUTRIGHT WINNER\/#INFO\/PREFERRED_BOOKMAKER","priceTopicD5":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/OUTRIGHT WINNER\/PREFERRED_DOG\/PREFERRED_BOOKMAKER","testingPriceTopic":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/OUTRIGHT WINNER\/PREFERRED_DOG\/PREFERRED_BOOKMAKER","distance":480,"raceGrade":"A9","raceTypeDesc":"Flat","raceDatetime":"1562137920","raceHour":"08","raceMin":"12","reserved":"","tvId":"","bagsCode":"S","raceTitle":"Race 1"},"card-tabs":{"raceId":"1706057","raceDate":"2019-07-03 08:12","distance":"480","raceStatus":0,"raceTitle":"Welcome To Kilkenny Track A9 525","bagsCode":"S","trackName":"KILKENNY","trackCde":"KILK","rpTrackShortName":"Kilky","trackId":"50","country":"IRE","typeDesc":"Flat","raceGrade":"A9","selTrapNum":"6","tvId":"","dangerTrapNum":"5","fcastAltTrapNum":"3","napNum":"","raceDateDate":"2019-07-03","raceDateTime":"08:12"},"card":{"dogs":[{"dogId":"528848","trackId":"50","trapNum":"1","dogName":"Flexible Pango","dogColor":"BK","dogSex":"B","forecastComment":"Been battered around lately, due some luck","chanceOfWin":30.72,"trainerName":"M Kennedy","trainerLocation":"","forecast":"5\/1","topSpeed":"93","wideYn":"","handicapMetre":"","diffusionName":"FLEXIBLE_PANGO","spotlightComment":"Been battered around lately, due some luck","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"1Sep15","brt":"30.57","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Farloe Tango","dam":"Flexible Dora","birthMonYY":"Sep15","dateOfSeason":"","shortForm":"53355"},{"dogId":"532977","trackId":"50","trapNum":"2","dogName":"Bradys Choice","dogColor":"BK","dogSex":"B","forecastComment":"Finding trouble, not showcasing ability as a result","chanceOfWin":30.78,"trainerName":"M Fortune","trainerLocation":"","forecast":"5\/1","topSpeed":"91","wideYn":"","handicapMetre":"","diffusionName":"BRADYS_CHOICE","spotlightComment":"Finding trouble, not showcasing ability as a result","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"11Jan18","brt":"30.67","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Ballymac Eske","dam":"Marinas Blue","birthMonYY":"Jan18","dateOfSeason":"","shortForm":"T5666"},{"dogId":"528978","trackId":"50","trapNum":"3","dogName":"Littlest Hobo","dogColor":"WBK","dogSex":"B","forecastComment":"Learning twists and turns of track, may still run well","chanceOfWin":30.42,"trainerName":"D Fogarty","trainerLocation":"","forecast":"4\/1","topSpeed":"99","wideYn":"","handicapMetre":"","diffusionName":"LITTLEST_HOBO","spotlightComment":"Learning twists and turns of track, may still run well","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"1May17","brt":"30.31","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Sidarian Blaze","dam":"Miss Precedent","birthMonYY":"May17","dateOfSeason":"","shortForm":"532T3"},{"dogId":"532964","trackId":"50","trapNum":"4","dogName":"Amwhatiam","dogColor":"BE","dogSex":"B","forecastComment":"Luck tends to even itself out, due a change of it","chanceOfWin":30.51,"trainerName":"S O'Donnell","trainerLocation":"","forecast":"7\/2","topSpeed":"96","wideYn":"","handicapMetre":"","diffusionName":"AMWHATIAM","spotlightComment":"Luck tends to even itself out, due a change of it","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"12Sep17","brt":"30.4","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Superior Product","dam":"Aclamon Jill","birthMonYY":"Sep17","dateOfSeason":"","shortForm":"TTT64"},{"dogId":"528832","trackId":"50","trapNum":"5","dogName":"Heyisntthatright","dogColor":"BK","dogSex":"B","forecastComment":"Five alive? Must be paw perfect to avoid a bang","chanceOfWin":30.33,"trainerName":"M Bergin-Flynn","trainerLocation":"","forecast":"7\/2","topSpeed":"100","wideYn":"","handicapMetre":"","diffusionName":"HEYISNTTHATRIGHT","spotlightComment":"Five alive? Must be paw perfect to avoid a bang","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"15Aug17","brt":"30.13","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Barefoot James","dam":"Hey Ruby","birthMonYY":"Aug17","dateOfSeason":"","shortForm":"44336"},{"dogId":"533139","trackId":"50","trapNum":"6","dogName":"Kilbreedy Hulk","dogColor":"BK","dogSex":"D","forecastComment":"Being backed with good reason, leading player","chanceOfWin":30.29,"trainerName":"F Hickey","trainerLocation":"","forecast":"9\/4","topSpeed":"99","wideYn":"M","handicapMetre":"","diffusionName":"KILBREEDY_HULK","spotlightComment":"Being backed with good reason, leading player","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"21Oct17","brt":"30.23","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Farloe Blitz","dam":"Garryglass Ros","birthMonYY":"Oct17","dateOfSeason":"","shortForm":"T6326"}]}}

card-header, card-title, card-tabs e card, são os objetos "principais"....

 

Por exemplo... se eu quero pegar apenas "distance" que está dentro do "card-header"estou usando...

 

foreach ($itens as $dados){
}

porém, está pegando "distance" de outros objetos, no caso que eu não queria....

 

então tentei assim...

foreach ($itens->card-header as $dados){
}

e assim

foreach ($itens->card-header as $dados=>$a){
}

 

Mas está me gerando erro no foreach...

Me salvem ai, como faço para acessar esses objetos "pai" separadamente... Me desculpe usar estes termos é que não sei realmente como chama-los!

 

Obrigado

 

Share this post


Link to post
Share on other sites

Transforme o JSON em ARRAY e use PRINT_R para mostrar na tela todo o conteúdo. 

Localize onde está o "distance" (ele não está dentro "card-header") e percorra os ARRAYS normalmente para obte-lo.

 

<?php

$json = '{"card-header":{"raceId":"1706057","races":{"95049":{"meeting_abandoned":0,"track":"Kilkenny","races":[{"raceId":"1706057","raceDate":"2019-07-03","raceTime":"8:12"},{"raceId":"1706058","raceDate":"2019-07-03","raceTime":"8:27"},{"raceId":"1706059","raceDate":"2019-07-03","raceTime":"8:43"},{"raceId":"1706060","raceDate":"2019-07-03","raceTime":"9:02"},{"raceId":"1706857","raceDate":"2019-07-03","raceTime":"9:18"},{"raceId":"1706858","raceDate":"2019-07-03","raceTime":"9:34"},{"raceId":"1706859","raceDate":"2019-07-03","raceTime":"9:52"},{"raceId":"1706860","raceDate":"2019-07-03","raceTime":"10:07"},{"raceId":"1706861","raceDate":"2019-07-03","raceTime":"10:23"},{"raceId":"1706862","raceDate":"2019-07-03","raceTime":"10:41"}],"track_id":"50","tv_id":"","tv_name":""}},"courseId":95049,"country":"IRE","trackAbbrName":"K\'kenny"},"card-title":{"postPick":"6-5-3","napNum":"","raceSisStatusTopicD5":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/#SIS_STATUS","infoTopicD5":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/OUTRIGHT WINNER\/#INFO\/PREFERRED_BOOKMAKER","priceTopicD5":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/OUTRIGHT WINNER\/PREFERRED_DOG\/PREFERRED_BOOKMAKER","testingPriceTopic":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/OUTRIGHT WINNER\/PREFERRED_DOG\/PREFERRED_BOOKMAKER","distance":480,"raceGrade":"A9","raceTypeDesc":"Flat","raceDatetime":"1562137920","raceHour":"08","raceMin":"12","reserved":"","tvId":"","bagsCode":"S","raceTitle":"Race 1"},"card-tabs":{"raceId":"1706057","raceDate":"2019-07-03 08:12","distance":"480","raceStatus":0,"raceTitle":"Welcome To Kilkenny Track A9 525","bagsCode":"S","trackName":"KILKENNY","trackCde":"KILK","rpTrackShortName":"Kilky","trackId":"50","country":"IRE","typeDesc":"Flat","raceGrade":"A9","selTrapNum":"6","tvId":"","dangerTrapNum":"5","fcastAltTrapNum":"3","napNum":"","raceDateDate":"2019-07-03","raceDateTime":"08:12"},"card":{"dogs":[{"dogId":"528848","trackId":"50","trapNum":"1","dogName":"Flexible Pango","dogColor":"BK","dogSex":"B","forecastComment":"Been battered around lately, due some luck","chanceOfWin":30.72,"trainerName":"M Kennedy","trainerLocation":"","forecast":"5\/1","topSpeed":"93","wideYn":"","handicapMetre":"","diffusionName":"FLEXIBLE_PANGO","spotlightComment":"Been battered around lately, due some luck","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"1Sep15","brt":"30.57","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Farloe Tango","dam":"Flexible Dora","birthMonYY":"Sep15","dateOfSeason":"","shortForm":"53355"},{"dogId":"532977","trackId":"50","trapNum":"2","dogName":"Bradys Choice","dogColor":"BK","dogSex":"B","forecastComment":"Finding trouble, not showcasing ability as a result","chanceOfWin":30.78,"trainerName":"M Fortune","trainerLocation":"","forecast":"5\/1","topSpeed":"91","wideYn":"","handicapMetre":"","diffusionName":"BRADYS_CHOICE","spotlightComment":"Finding trouble, not showcasing ability as a result","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"11Jan18","brt":"30.67","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Ballymac Eske","dam":"Marinas Blue","birthMonYY":"Jan18","dateOfSeason":"","shortForm":"T5666"},{"dogId":"528978","trackId":"50","trapNum":"3","dogName":"Littlest Hobo","dogColor":"WBK","dogSex":"B","forecastComment":"Learning twists and turns of track, may still run well","chanceOfWin":30.42,"trainerName":"D Fogarty","trainerLocation":"","forecast":"4\/1","topSpeed":"99","wideYn":"","handicapMetre":"","diffusionName":"LITTLEST_HOBO","spotlightComment":"Learning twists and turns of track, may still run well","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"1May17","brt":"30.31","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Sidarian Blaze","dam":"Miss Precedent","birthMonYY":"May17","dateOfSeason":"","shortForm":"532T3"},{"dogId":"532964","trackId":"50","trapNum":"4","dogName":"Amwhatiam","dogColor":"BE","dogSex":"B","forecastComment":"Luck tends to even itself out, due a change of it","chanceOfWin":30.51,"trainerName":"S O\'Donnell","trainerLocation":"","forecast":"7\/2","topSpeed":"96","wideYn":"","handicapMetre":"","diffusionName":"AMWHATIAM","spotlightComment":"Luck tends to even itself out, due a change of it","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"12Sep17","brt":"30.4","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Superior Product","dam":"Aclamon Jill","birthMonYY":"Sep17","dateOfSeason":"","shortForm":"TTT64"},{"dogId":"528832","trackId":"50","trapNum":"5","dogName":"Heyisntthatright","dogColor":"BK","dogSex":"B","forecastComment":"Five alive? Must be paw perfect to avoid a bang","chanceOfWin":30.33,"trainerName":"M Bergin-Flynn","trainerLocation":"","forecast":"7\/2","topSpeed":"100","wideYn":"","handicapMetre":"","diffusionName":"HEYISNTTHATRIGHT","spotlightComment":"Five alive? Must be paw perfect to avoid a bang","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"15Aug17","brt":"30.13","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Barefoot James","dam":"Hey Ruby","birthMonYY":"Aug17","dateOfSeason":"","shortForm":"44336"},{"dogId":"533139","trackId":"50","trapNum":"6","dogName":"Kilbreedy Hulk","dogColor":"BK","dogSex":"D","forecastComment":"Being backed with good reason, leading player","chanceOfWin":30.29,"trainerName":"F Hickey","trainerLocation":"","forecast":"9\/4","topSpeed":"99","wideYn":"M","handicapMetre":"","diffusionName":"KILBREEDY_HULK","spotlightComment":"Being backed with good reason, leading player","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"21Oct17","brt":"30.23","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Farloe Blitz","dam":"Garryglass Ros","birthMonYY":"Oct17","dateOfSeason":"","shortForm":"T6326"}]}}';
$json = json_decode($json, TRUE);

print_r($json['card-title']['distance']);

 

Share this post


Link to post
Share on other sites
2 horas atrás, Robson Lopes disse:

Transforme o JSON em ARRAY e use PRINT_R para mostrar na tela todo o conteúdo. 

Localize onde está o "distance" (ele não está dentro "card-header") e percorra os ARRAYS normalmente para obte-lo.

 


<?php

$json = '{"card-header":{"raceId":"1706057","races":{"95049":{"meeting_abandoned":0,"track":"Kilkenny","races":[{"raceId":"1706057","raceDate":"2019-07-03","raceTime":"8:12"},{"raceId":"1706058","raceDate":"2019-07-03","raceTime":"8:27"},{"raceId":"1706059","raceDate":"2019-07-03","raceTime":"8:43"},{"raceId":"1706060","raceDate":"2019-07-03","raceTime":"9:02"},{"raceId":"1706857","raceDate":"2019-07-03","raceTime":"9:18"},{"raceId":"1706858","raceDate":"2019-07-03","raceTime":"9:34"},{"raceId":"1706859","raceDate":"2019-07-03","raceTime":"9:52"},{"raceId":"1706860","raceDate":"2019-07-03","raceTime":"10:07"},{"raceId":"1706861","raceDate":"2019-07-03","raceTime":"10:23"},{"raceId":"1706862","raceDate":"2019-07-03","raceTime":"10:41"}],"track_id":"50","tv_id":"","tv_name":""}},"courseId":95049,"country":"IRE","trackAbbrName":"K\'kenny"},"card-title":{"postPick":"6-5-3","napNum":"","raceSisStatusTopicD5":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/#SIS_STATUS","infoTopicD5":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/OUTRIGHT WINNER\/#INFO\/PREFERRED_BOOKMAKER","priceTopicD5":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/OUTRIGHT WINNER\/PREFERRED_DOG\/PREFERRED_BOOKMAKER","testingPriceTopic":"GREYHOUNDS\/2019-07-03\/KILKENNY\/08:12\/OUTRIGHT WINNER\/PREFERRED_DOG\/PREFERRED_BOOKMAKER","distance":480,"raceGrade":"A9","raceTypeDesc":"Flat","raceDatetime":"1562137920","raceHour":"08","raceMin":"12","reserved":"","tvId":"","bagsCode":"S","raceTitle":"Race 1"},"card-tabs":{"raceId":"1706057","raceDate":"2019-07-03 08:12","distance":"480","raceStatus":0,"raceTitle":"Welcome To Kilkenny Track A9 525","bagsCode":"S","trackName":"KILKENNY","trackCde":"KILK","rpTrackShortName":"Kilky","trackId":"50","country":"IRE","typeDesc":"Flat","raceGrade":"A9","selTrapNum":"6","tvId":"","dangerTrapNum":"5","fcastAltTrapNum":"3","napNum":"","raceDateDate":"2019-07-03","raceDateTime":"08:12"},"card":{"dogs":[{"dogId":"528848","trackId":"50","trapNum":"1","dogName":"Flexible Pango","dogColor":"BK","dogSex":"B","forecastComment":"Been battered around lately, due some luck","chanceOfWin":30.72,"trainerName":"M Kennedy","trainerLocation":"","forecast":"5\/1","topSpeed":"93","wideYn":"","handicapMetre":"","diffusionName":"FLEXIBLE_PANGO","spotlightComment":"Been battered around lately, due some luck","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"1Sep15","brt":"30.57","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Farloe Tango","dam":"Flexible Dora","birthMonYY":"Sep15","dateOfSeason":"","shortForm":"53355"},{"dogId":"532977","trackId":"50","trapNum":"2","dogName":"Bradys Choice","dogColor":"BK","dogSex":"B","forecastComment":"Finding trouble, not showcasing ability as a result","chanceOfWin":30.78,"trainerName":"M Fortune","trainerLocation":"","forecast":"5\/1","topSpeed":"91","wideYn":"","handicapMetre":"","diffusionName":"BRADYS_CHOICE","spotlightComment":"Finding trouble, not showcasing ability as a result","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"11Jan18","brt":"30.67","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Ballymac Eske","dam":"Marinas Blue","birthMonYY":"Jan18","dateOfSeason":"","shortForm":"T5666"},{"dogId":"528978","trackId":"50","trapNum":"3","dogName":"Littlest Hobo","dogColor":"WBK","dogSex":"B","forecastComment":"Learning twists and turns of track, may still run well","chanceOfWin":30.42,"trainerName":"D Fogarty","trainerLocation":"","forecast":"4\/1","topSpeed":"99","wideYn":"","handicapMetre":"","diffusionName":"LITTLEST_HOBO","spotlightComment":"Learning twists and turns of track, may still run well","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"1May17","brt":"30.31","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Sidarian Blaze","dam":"Miss Precedent","birthMonYY":"May17","dateOfSeason":"","shortForm":"532T3"},{"dogId":"532964","trackId":"50","trapNum":"4","dogName":"Amwhatiam","dogColor":"BE","dogSex":"B","forecastComment":"Luck tends to even itself out, due a change of it","chanceOfWin":30.51,"trainerName":"S O\'Donnell","trainerLocation":"","forecast":"7\/2","topSpeed":"96","wideYn":"","handicapMetre":"","diffusionName":"AMWHATIAM","spotlightComment":"Luck tends to even itself out, due a change of it","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"12Sep17","brt":"30.4","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Superior Product","dam":"Aclamon Jill","birthMonYY":"Sep17","dateOfSeason":"","shortForm":"TTT64"},{"dogId":"528832","trackId":"50","trapNum":"5","dogName":"Heyisntthatright","dogColor":"BK","dogSex":"B","forecastComment":"Five alive? Must be paw perfect to avoid a bang","chanceOfWin":30.33,"trainerName":"M Bergin-Flynn","trainerLocation":"","forecast":"7\/2","topSpeed":"100","wideYn":"","handicapMetre":"","diffusionName":"HEYISNTTHATRIGHT","spotlightComment":"Five alive? Must be paw perfect to avoid a bang","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"15Aug17","brt":"30.13","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Barefoot James","dam":"Hey Ruby","birthMonYY":"Aug17","dateOfSeason":"","shortForm":"44336"},{"dogId":"533139","trackId":"50","trapNum":"6","dogName":"Kilbreedy Hulk","dogColor":"BK","dogSex":"D","forecastComment":"Being backed with good reason, leading player","chanceOfWin":30.29,"trainerName":"F Hickey","trainerLocation":"","forecast":"9\/4","topSpeed":"99","wideYn":"M","handicapMetre":"","diffusionName":"KILBREEDY_HULK","spotlightComment":"Being backed with good reason, leading player","nonRunner":"","reserved":"","isVacant":"","dateOfBirth":"21Oct17","brt":"30.23","bestTimeGrade":"","bestTimeGradeDate":"","sire":"Farloe Blitz","dam":"Garryglass Ros","birthMonYY":"Oct17","dateOfSeason":"","shortForm":"T6326"}]}}';
$json = json_decode($json, TRUE);

print_r($json['card-title']['distance']);

 

eu tinha tentado essa opção já, e infelizmente não funcionou, vou testar de novo e volto aqui para reportar o erro caso não de certo!

Mas nesse caso, como deve ser o foreach()? Existem outros itens dentro do array que preciso que sejam pegos no laço, por exemplo o item races, que são vários dentro de um, sacou?

 

PS: usei o "distance" como exemplo rápido, ele aparece duas vezes, uma no "card-tabs" e outra no "card-title", de toda forma, por exemplo, por objeto quando pedia para imprimir o "distance" do card-tabs, o sistema me retornava assim:

 

distancia:     (vazio pq no card-header não tem)

distancia: 480  (do card-title)

distancia: 480 (do card-tabs)

distancia:     (vazio, nao presente em "cards")

 

ele percorria todo o json mesmo eu direcionando o objeto... $json->card-tabs, por exemplo!!!

 

 

de toda forma obrigado

 

Share this post


Link to post
Share on other sites

Quando os dados de um foreach forem outro array, você precisa fazer outro foreach dentro dele. Um foreach dentro de outro, quantos forem necessários para pegar as informações que você quer.

 

foreach($json as $dados)
{
	foreach($dados as $dados2)
	{
		...
	}
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By infonet
      Poderiam me ajudar com esta consulta SQL?   Acontece que ela roda normal, mas quando coloco na paginação ela não funciona:   mysqli_query ($conn, "SET @a := 0"); $_pagi_sql = "SELECT *, LPAD( @a := @a + 1, 5, '0' ) 'sequencial' FROM tb_his WHERE idclih = $idclientHis ORDER BY dt_his DESC, idhis DESC, sequencial DESC";   O erro acontece somente por causa do final: sequencial DESC, pois quando eu retiro, funciona normalmente.   Obrigado!
    • By Eurales antony
      Boa noite developers, eu codei um sistema em PHP mas não para ser vendido e sim alugado, o cliente aluga eu envio os arquivos do sistema e uma chave e apenas com uma chave valida o sistema funciona, o sistema está pronto terminei de coda o ofuscador e um contaminador(insere códigos deanecesaarios no código) mas agora eu preciso criptografar todos os arquivos, tipo base_64 ou melhor, com o ofuscador e contaminador o código fonte está totalmente ilegível mas quero que fique igual a um código que eu vi, um monte de caracteres nada vê com nada não sei se era base 64 na verdade não entendo muito sobre criptografia quem puder me ajudar eu agradeço e quem chegou até aqui agrade pelo atenção, boa noite 
    • By eduardaarosaa
      Olá!!! Gostaria de saber como converter um objeto em array.
      Já tentei usar get_objet_vars e não funcionou ... veio um array vazio 
      Exemplo: array(){
      }
      array(){
      }
      Meu objeto está assim: 
      object(Illuminate\Http\UploadedFile)#205 (7) {
        ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        bool(false)
        ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(10) "eliete.jpg"
        ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(10) "image/jpeg"
        ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        int(0)
        ["hashName":protected]=>
        NULL
        ["pathName":"SplFileInfo":private]=>
        string(24) "C:\xampp\tmp\php8467.tmp"
        ["fileName":"SplFileInfo":private]=>
        string(11) "php8467.tmp"
      }
      object(Illuminate\Http\UploadedFile)#211 (7) {
        ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        bool(false)
        ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(40) "f114abec-1fe1-4e86-92b0-5b976b4c50c0.jpg"
        ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(10) "image/jpeg"
        ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        int(0)
        ["hashName":protected]=>
        NULL
        ["pathName":"SplFileInfo":private]=>
        string(24) "C:\xampp\tmp\php8468.tmp"
        ["fileName":"SplFileInfo":private]=>
        string(11) "php8468.tmp"
      }
      object(Illuminate\Http\UploadedFile)#212 (7) {
        ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        bool(false)
        ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(27) "bitcoin-3125488_960_720.png"
        ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(9) "image/png"
        ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        int(0)
        ["hashName":protected]=>
        NULL
        ["pathName":"SplFileInfo":private]=>
        string(24) "C:\xampp\tmp\php8469.tmp"
        ["fileName":"SplFileInfo":private]=>
        string(11) "php8469.tmp"
      }
      object(Illuminate\Http\UploadedFile)#213 (7) {
        ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        bool(false)
        ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(14) "imagem0033.jpg"
        ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(10) "image/jpeg"
        ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        int(0)
        ["hashName":protected]=>
        NULL
        ["pathName":"SplFileInfo":private]=>
        string(24) "C:\xampp\tmp\php8479.tmp"
        ["fileName":"SplFileInfo":private]=>
        string(11) "php8479.tmp"
      }
       
      Obrigada!!!
    • By eduardaarosaa
      Olá!!! Gostaria de saber como converter um objeto em array.
      Já tentei usar get_objet_vars e não funcionou ... veio um array vazio 
      Exemplo: array(){
      }
      array(){
      }
      Meu objeto está assim: 
      object(Illuminate\Http\UploadedFile)#205 (7) {
        ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        bool(false)
        ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(10) "eliete.jpg"
        ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(10) "image/jpeg"
        ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        int(0)
        ["hashName":protected]=>
        NULL
        ["pathName":"SplFileInfo":private]=>
        string(24) "C:\xampp\tmp\php8467.tmp"
        ["fileName":"SplFileInfo":private]=>
        string(11) "php8467.tmp"
      }
      object(Illuminate\Http\UploadedFile)#211 (7) {
        ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        bool(false)
        ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(40) "f114abec-1fe1-4e86-92b0-5b976b4c50c0.jpg"
        ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(10) "image/jpeg"
        ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        int(0)
        ["hashName":protected]=>
        NULL
        ["pathName":"SplFileInfo":private]=>
        string(24) "C:\xampp\tmp\php8468.tmp"
        ["fileName":"SplFileInfo":private]=>
        string(11) "php8468.tmp"
      }
      object(Illuminate\Http\UploadedFile)#212 (7) {
        ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        bool(false)
        ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(27) "bitcoin-3125488_960_720.png"
        ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(9) "image/png"
        ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        int(0)
        ["hashName":protected]=>
        NULL
        ["pathName":"SplFileInfo":private]=>
        string(24) "C:\xampp\tmp\php8469.tmp"
        ["fileName":"SplFileInfo":private]=>
        string(11) "php8469.tmp"
      }
      object(Illuminate\Http\UploadedFile)#213 (7) {
        ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        bool(false)
        ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(14) "imagem0033.jpg"
        ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        string(10) "image/jpeg"
        ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
        int(0)
        ["hashName":protected]=>
        NULL
        ["pathName":"SplFileInfo":private]=>
        string(24) "C:\xampp\tmp\php8479.tmp"
        ["fileName":"SplFileInfo":private]=>
        string(11) "php8479.tmp"
      }
       
      Obrigada!!!
    • By RewelB
      Olá, gostaria de saber como faço pra que quando o usuário digite algo em um campo de texto a imagem fique girando. Eu tenho a imagem de uma engrenagem e queria que ela fizesse uma animaçãozinha no estilo da que tem nesse site: http://www.empsis.com.br/. Sou iniciante e peço desculpas se isso for muito simples de fazer. Estou usando PHP, HTML e CSS.
×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.