PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

ECHOING ARRAY VALUES

You can echo array values or use these values directly in your statements.

Say you have an array:

$colors=array('blue', 'red', 'green');

The above is equivalent to:

$colors[0]="blue";
$colors[1]="red";
$colors[2]="green";

To echo, simply do:

echo $colors[0]; // outputs blue
echo $colors[1]; // outputs red
echo $colors[2]; // outputs green

Or you can a declare a variable for each value as folows:

$firstcolor=$colors[0];
$secondcolor=$colors[1];
$thirdcolor=$colors[2];

And then echo the variable as follows:

echo $firstcolor; // outputs blue
echo $secondcolor; // outputs red
echo $thirdcolor; // outputs green

See also:

What Are Arrays?
How To Create Arrays
How To View Arrays
How To Modify Arrays
Array arsort() Function
Array asort() Function
Array rsort() Function
Array sort() Function
Array ksort() Function
Array krsort() Function
Array list() Function
Manual Array Iteration
Array count() & sizeof() Function




Home | Privacy Policy | Terms Of Use | Contact Us | Work At Home | Online Jobs | Smart Info | Online Jobs | Data Entry Jobs | Paid Surveys | Info | Info | Typing Jobs | Article Archive | Forum Posting Jobs