Skip to content

Instantly share code, notes, and snippets.

@kinncj
Created August 13, 2015 14:18
Show Gist options
  • Save kinncj/8c1e61159702bee4fc3d to your computer and use it in GitHub Desktop.
Save kinncj/8c1e61159702bee4fc3d to your computer and use it in GitHub Desktop.
ZCEs from CANADA
<?php
function readStdin($message = null)
{
if ($message) {
echo $message.PHP_EOL;
}
$fr=fopen("php://stdin","r");
$input = fgets($fr,128);
$input = rtrim($input);
fclose ($fr);
return $input;
}
function sortData($a, $b)
{
return new \DateTime($a['date']) > new \DateTime($b['date']) ? +1 : -1;
}
function getUserList()
{
$data = file_get_contents('http://www.zend.com/en/services/certification/zend-certified-engineer-directory/ajax/search-candidates?cid=39&sid=&certtype_php=on&certtype=PHP&firstname=&lastname=&company=&ClientCandidateID=');
$data = json_decode($data);
$userList = [];
foreach ($data->result as $user) {
if (strpos($user->exams, EXAM_CODE) === false) {
continue;
}
$exams = (array) explode(",", $user->exams);
$examsDates = (array) explode(",", $user->examdates);
foreach ($exams as $key=>$exam) {
if($exam == '200-550') {
$examDate = $examsDates[$key];
}
}
$user->zendimage = 'http://www.zend.com/images/training/zce_photos/' . $user->zendimage;
$userList[] = [
'name' => $user->firstname . ' '. $user->lastname,
'date' => $examDate,
'raw' => $user,
];
}
return $userList;
}
$examCode = readStdin('Type the exam code. eg: 200-550');
if (empty($examCode)) {
$examCode = '200-550';
}
define(EXAM_CODE, $examCode);
$userList = getUserList();
usort($userList, "sortData");
echo json_encode($userList);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment