0

The only thing i thought of was this trying to make this code work:

$index = [$player]['matchHistory'][$matchIndex];
$players . $index . ['platformId'];

Trying to get this final outcome

$players[$playerIndex]['matchHistory'][$matchIndex]['platformId'];

But with this code, i get this error

Fatal error: Assignments can only happen to writable values in C:\Users\elvarp\Documents\webdev\iceleague\testing.php on line 39

Is this possible in php? Don't have enough knowledge to google this around.

EDIT: Full code i'm working with:

foreach ($players as $playerIndex => $player) {
  $matchHistory = $api->getRecentMatchList($player['summonerAccountId'], "season=9");
  foreach ($matchHistory['matches'] as $matchIndex => $match) {
    $index = [$playerIndex]['matchHistory'][$matchIndex];
    $players . $index . ['platformId'] = $match['platformId'];
    $players . $index . ['matchId'] = $match['gameId'];
    $players . $index . ['championId'] = $match['champion'];
    $players . $index . ['queue'] = $match['queue'];
    $players . $index . ['season'] = $match['season'];
    $players . $index . ['timestamp'] = $match['timestamp'];
    $players . $index . ['role'] = $match['role'];
    $players . $index . ['lane'] = $match['lane'];
  }
}

The value of $player

Array
(
    [summonerName] => Retro
    [summonerId] => 27467980
    [summonerAccountId] => 31905356
)
7
  • Which line is your error ? This : $players . $index . ['platformId']; ? Commented Jul 21, 2017 at 10:32
  • can you show values of $player,$matchIndex,$playerIndex? Commented Jul 21, 2017 at 10:33
  • Sorry forgot to put in the line which gives me the error. This is it. $players . $index . ['platformId'] = $match['platformId']; Commented Jul 21, 2017 at 10:35
  • I edited the post to show the full code i'm working with. Commented Jul 21, 2017 at 10:39
  • Uhm… how about just $players[$playerIndex]['matchHistory'][$matchIndex] = $match;…? There appears to be little point in you assigning each key in $match to $players manually. If you simply assign the whole array at once, your problem disappears entirely. Commented Jul 21, 2017 at 12:52

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.