- print_r: documentation ( source)
<?php
class Student
{
public $studentnummer;
public $voornaam;
}
$apiResult = [
'firstName' => 'Barry',
'sid' => 'S123',
];
$map = [
'firstName' => 'voornaam',
'sid' => 'studentnummer',
];
$student = new Student;
foreach ($apiResult as $key => $value) {
if (isset($map[$key])) {
$student->{$map[$key]} = $value;
}
}
print_r($student);