Now, in a case like earlier, you already knew what all the variables were going to equal. PHP offers a great way to create your array elements at the same time as creating arrays. This requires the => operator, and the array declaration is done at the time array() is called. Look at the basic structure:
$newarray = array(key => value, key => value, ...)
As you can see, we are calling array() with a list of parameters. You can create as many keys as you want, and all of them will be part of $newarray.
Let’s rewrite the program using this new syntax. This is phpft10-02.php and you can find it on the CD. In addition to changing the preceding program’s syntax, I added <br /> tags to make it cleaner.
<?php $newarray = array(1 ...