Salocin.TEN This is the digital media portfolio

Link to this

Embed this on the web:

Embed this on artician:

Facebook Interview PHP Screening Test

by Salocin.TEN
loadHTML(file_get_contents('http://.../fbtest2/gettoken.php')); $grabToken = new DOMXPath($tokenMachine); $tokenGrabber = $grabToken->query('//span[@id="token"]'); foreach ($tokenGrabber as $tokenGrab) { return $tokenGrab->nodeValue; } } $_SESSION['token'] = generateToken(); /** * @name listProjects * @return Array of student project records. */ function listProjects() { $listMachine = new DOMDocument(); $listMachine->loadHTML(file_get_contents('http://.../fbtest2/list.php?token='.$_SESSION['token'])); $getList = new DOMXPath($listMachine); $listGrabber1 = $getList->query('//table[@id="mytable"]/tbody/tr/td[1]'); // For student IDs. $listGrabber2 = $getList->query('//table[@id="mytable"]/tbody/tr/td[2]'); // For project titles. $outputArray = array(); $outputArray1 = array(); $outputArray2 = array(); foreach ($listGrabber1 as $listGrabbed1) { array_push($outputArray1, strtolower(str_ireplace(' ', '', $listGrabbed1->nodeValue))); } unset($listGrabbed1); foreach ($listGrabber2 as $listGrabbed2) { array_push($outputArray2, htmlspecialchars_decode($listGrabbed2->nodeValue)); } unset($listGrabbed2); $outputArray = array_combine($outputArray2, $outputArray1); $resultArray = array(); foreach(array_keys($outputArray) as $key) { if(array_key_exists($outputArray[$key],$resultArray)) { $resultArray[$outputArray[$key]] = array_merge((array)$resultArray[$outputArray[$key]], (array)$key); } else { $resultArray[$outputArray[$key]] = $key; } } return $resultArray; } /** * HTML output starts here. If this was the real world, the PHP code above would have been stored in the model and controller layer, * and the following in the view layer. */ ?> Facebook Programming Puzzle

List of Students' Projects

$projectTitles) { echo "".$studentName."
"; if(is_array($projectTitles)) { foreach($projectTitles as $projectCount => $projectTitle) { echo $projectTitle."
"; }; } else { echo $projectTitles."
"; } echo "
"; } ?>
Report
Description: Pre screening test for a Facebook interview.

I got through this pre-screening, but not through the interview.

So it is pretty much open now.
Tag it

You must be logged in to post a comment. Login or Join Artician, Free.