Uploaded on

PHP lecture 03 …

PHP lecture 03
PHP Array Functions
PHP Array Functions overview.
count() - return the number of elements of an array.
sort() - sort arrays in ascending order.
For Loop

More in: Education , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
248
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
19
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. PHP Course 3: Arrays An array stores multiple values in one single variable PHP Course Info@ITBigDig.com
  • 2. Instructor  Name: Mohamed Saad.  Email: Engsaad_aly@hotmail.com  Occupation: Web Developer In IT Big Dig. PHP Course Info@ITBigDig.com
  • 3. Contents • PHP Array Functions o PHP Array Functions overview. o count() - return the number of elements of an array. o sort() - sort arrays in ascending order. • For Loop PHP Course Info@ITBigDig.com
  • 4. PHP Array Functions overview o count() - return the number of elements of an array. o sort() - sort arrays in ascending order. o rsort() - sort arrays in descending order. o asort() - sort associative arrays in ascending order, according to the value. o ksort() - sort associative arrays in ascending order, according to the key. o arsort() - sort associative arrays in descending order, according to the value. o krsort() - sort associative arrays in descending order, according to the key.
  • 5. PHP Array • There are three types of arrays: •Arrays with numeric indexIndexed arrays •Arrays with named keysAssociative arrays •Arrays containing one or more arraysMultidimensional arrays
  • 6. array() Function Syntax •array(‘value’, );indexed •array(‘key’ =>’value’, );associative
  • 7. count() Function Syntax o $x=array("Volvo“,"BMW“,"Toyota"); echo count($x);
  • 8. sort() Function
  • 9. <?php $x=array("Volvo","BMW","Toyota","Audi"); sort($x); $var_count=count($x); for($i=0;$i<$var_count;$i++) { echo $x[$i]; echo "<br>"; } ?> Copy Code array1.php PHP Course Info@ITBigDig.com
  • 10. For Loop Syntax o for (Counter; condition; increment) { code to be executed; } PHP Course Info@ITBigDig.com
  • 11. Loop Through an Indexed Array
  • 12. <?php $cars=array("Volvo","BMW","Toyota"); $arrlength=count($cars); echo $arrlength,"<br>"; for($x=0;$x<$arrlength;$x++) { echo $cars[$x]; echo "<br>"; } ?> Copy Code for.php PHP Course Info@ITBigDig.com
  • 13. We hope You enjoy This Tutorial. For any Suggestions Please Email Us Info@ITBigDig.com PHP Course Info@ITBigDig.com End Arrays