Home | Programming | Php
Last week we started exploring the very basics of PHP programming. We started by first discussing the Web Server/Browser relationship, then began looking at PHP by first introducing how to comment our PHP code which is very important. We then introduced the echo and print functions, and demonstrated how to use variables and the variable naming rules. We also showed how to use concatenation. The next step in our quest to conquer PHP is to explore arrays which are similar to variables. Arrays are used when you would like to create many variables which will be similar. Rather than create hundreds of variables, a single array could be used to store all of the related values. Each element in the array will have its own ID number which you can then use to find the desired value. For example:
<?php $website[0] = "www.webdevnotes.com"; $website[1] = "www.looble.com"; $website[2] = "www.battlecity.net"; ?>
<?php $luckyNumber["Deceth"] = 11; $luckyNumber["Bob"] = 67; $luckyNumber["Harold"] = 99; ?>
<?php print "Bob's lucky number is " . $luckyNumber["Bob"]; ?>
Article Source: http://www.writerdatabase.com
www.webdevnotes.com/taking-advantage-of-arrays/
Please Rate this Article
5 out of 54 out of 53 out of 52 out of 51 out of 5
Not yet Rated