Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Problem z Pętlą.
TheBill
post 7.05.2014, 19:53:04
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 28.04.2014

Ostrzeżenie: (0%)
-----


Stworzyłem sobie pętlę na miarę moich możliwości ale mam pewien problem.
Wywala mi powiadomienie: Notice: Array to string conversion in..... line (tutaj 15)

I teraz nie wiem czy pętla do d.. czy jak

var_dump($SummonersIds):
Kod
array(3) { [0]=> array(1) { ["IDs"]=> int(39588825) } [1]=> array(1) { ["IDs"]=> int(37137364) } [2]=> array(1) { ["IDs"]=> int(39548730) } }



  1.  
  2. }
  3.  
  4. foreach ($sumData as $SummonersArrayID)
  5. {
  6. array_push($SummonersIds, array(
  7. "IDs" => $SummonersArrayID["id"]
  8. ));
  9. }
  10.  
  11. var_dump($SummonersIds);
  12.  
  13. $i= 0;
  14.  
  15. foreach ($SummonersIds as $sumID) {$tierresponse = Unirest::get("https://community-league-of-legends.p.mashape.com/api/v1.0/eune/summoner/getLeagueForPlayer/$sumID",
  16. array("X-Mashape-Authorization" => "$APIkey"), null);
  17. $arrayTier1 = ($tierresponse->raw_body);
  18. $sum1Tier[$i] = json_decode($arrayTier1, true);
  19.  
  20. $i = $i + 1;
  21. }
  22.  


Podpowie ktoś jak to ogarnąć?
Go to the top of the page
+Quote Post
Turson
post 7.05.2014, 19:59:33
Post #2





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


  1. $tierresponse = Unirest::get("https://community-league-of-legends.p.mashape.com/api/v1.0/eune/summoner/getLeagueForPlayer/".$sumID['IDs'],
Go to the top of the page
+Quote Post
TheBill
post 8.05.2014, 15:06:59
Post #3





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 28.04.2014

Ostrzeżenie: (0%)
-----


Nie zakładam nowego tematu bo wciąż mam ten sam problem.
Niestety byłem zmuszony przestawić się na oficjalne API.

O ile w poprzednim wszystko było dla mnie bardziej czytelne to tutaj już tak nie jest.

Przepisałem kod:
  1. $summonerlist = $nicknamelist;
  2.  
  3. $url1 = "http://prod.api.pvp.net/api/lol/eune/v1.4/summoner/by-name/$summonerlist?api_key=$key";
  4. $JSON1 = file_get_contents($url1);
  5. $sumData = json_decode($JSON1, true);
  6.  
  7. foreach ($sumData as $SummonersArray)
  8. {
  9. array_push($Summoners, array(
  10. "summonerName" => $SummonersArray["name"],
  11. "summonerID" => $SummonersArray["id"]));
  12. }
  13.  
  14. $i = 0;
  15. foreach ($Summoners as $sumID)
  16. {
  17. $JSON2 = file_get_contents("http://prod.api.pvp.net/api/lol/eune/v2.4/league/by-summoner/" .
  18. $sumID['summonerID'] . "/entry?api_key=" . $key);
  19. $sum1Tier[$i] = json_decode($JSON2, true);
  20. $i = $i + 1;
  21. }


Chciałbym teraz dane zwracane przez $sum1Tier ( http://pastebin.com/Km4HAwVX)
wcisnąć w nową tablicę ale nie wiem jak się za to zabrać.
Udaje mi się tylko dane pojedynczego gracza.
Czy da się to wogóle zrobić taką pętlą?


  1. foreach ($sum1Tier as $sumTierArr)
  2. {
  3. array_push($SummonerTIER, array(
  4. "summonerID" => $sumTierArr["playerOrTeamId"],
  5. "summonerName" => $sumTierArr["playerOrTeamName"],
  6. "summonerTIER" => $sumTierArr["tier"],
  7. "summonerRANK" => $sumTierArr["division"]
  8. ));
  9. }


Ten post edytował TheBill 8.05.2014, 15:10:39
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.04.2024 - 14:53