May 2017
Intermediate to advanced
340 pages
8h 16m
English
We are now going to convert our pseudocodes to actual PHP 7 codes as shown:
function findABook(Array $bookList, String $bookName) { $found = FALSE; foreach($bookList as $index => $book) { if($book === $bookName) { $found = $index; break; } } return $found; } function placeAllBooks(Array $orderedBooks, Array &$bookList) { foreach ($orderedBooks as $book) { $bookFound = findABook($bookList, $book); if($bookFound !== FALSE) { array_splice($bookList, $bookFound, 1); } } } $bookList = ['PHP','MySQL','PGSQL','Oracle','Java']; $orderedBooks = ['MySQL','PGSQL','Java']; placeAllBooks($orderedBooks, $bookList);echo implode(",", $bookList);
Let us now understand what is happening in the preceding code. ...
Read now
Unlock full access