Populate three arrays with book data
Original state of the arrays
Title data
Array
(
[0] => The Grapes of Wrath
[1] => The Trial
[2] => The Hobit
[3] => Tale of Two Cities
)
Author data
Array
(
[0] => John Steinbeck
[1] => Frances Kafka
[2] => J. R. Tolkien
[3] => Charles Dickens
)
Published Date data
Array
(
[0] => 1939
[1] => 1925
[2] => 1937
[3] => 1859
)
Sort arrays by Title
Title data
Array
(
[0] => Tale of Two Cities
[1] => The Grapes of Wrath
[2] => The Hobit
[3] => The Trial
)
Author data
Array
(
[0] => Charles Dickens
[1] => John Steinbeck
[2] => J. R. Tolkien
[3] => Frances Kafka
)
Published Date data
Array
(
[0] => 1859
[1] => 1939
[2] => 1937
[3] => 1925
)
Sort arrays by Author
Title data
Array
(
[0] => Tale of Two Cities
[1] => The Trial
[2] => The Hobit
[3] => The Grapes of Wrath
)
Author data
Array
(
[0] => Charles Dickens
[1] => Frances Kafka
[2] => J. R. Tolkien
[3] => John Steinbeck
)
Published Date data
Array
(
[0] => 1859
[1] => 1925
[2] => 1937
[3] => 1939
)
Sort arrays by Date Published
Title data
Array
(
[0] => Tale of Two Cities
[1] => The Trial
[2] => The Hobit
[3] => The Grapes of Wrath
)
Author data
Array
(
[0] => Charles Dickens
[1] => Frances Kafka
[2] => J. R. Tolkien
[3] => John Steinbeck
)
Published Date data
Array
(
[0] => 1859
[1] => 1925
[2] => 1937
[3] => 1939
)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arrays Revisited</title>
<link rel="stylesheet" href="../css/assignmentHeaderStyles.css" />
</head>
<body>
<?php
include('../header/assignmentHeader.php');
error_reporting(E_ALL);
echo('<h3>Arrays Revisited (array_multisort)</h3>');
echo('<p>Populate three arrays with book data</p>');
$titles = array('The Grapes of Wrath', 'The Trial', 'The Hobit', 'Tale of Two Cities');
$authors = array('John Steinbeck', 'Frances Kafka', 'J. R. Tolkien', 'Charles Dickens');
$published = array('1939', '1925', '1937', '1859');
echo('<p>Original state of the arrays</p>');
echo('<p>Title data</p><pre>');
print_r($titles);
echo('</pre>');
echo('<p>Author data</p><pre>');
print_r($authors);
echo('</pre>');
echo('<p>Published Date data</p><pre>');
print_r($published);
echo('</pre>');
echo('<p>Sort arrays by Title</p>');
array_multisort($titles, $authors, $published);
echo('<p>Title data</p><pre>');
print_r($titles);
echo('</pre>');
echo('<p>Author data</p><pre>');
print_r($authors);
echo('</pre>');
echo('<p>Published Date data</p><pre>');
print_r($published);
echo('</pre>');
echo('<p>Sort arrays by Author</p>');
array_multisort($authors, $titles, $published);
echo('<p>Title data</p><pre>');
print_r($titles);
echo('</pre>');
echo('<p>Author data</p><pre>');
print_r($authors);
echo('</pre>');
echo('<p>Published Date data</p><pre>');
print_r($published);
echo('</pre>');
echo('<p>Sort arrays by Date Published</p>');
array_multisort($published, $titles, $authors);
echo('<p>Title data</p><pre>');
print_r($titles);
echo('</pre>');
echo('<p>Author data</p><pre>');
print_r($authors);
echo('</pre>');
echo('<p>Published Date data</p><pre>');
print_r($published);
echo('</pre>');
show_source(__FILE__);
include('../footer/footer.php');
?>
</body>
</html>