• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

PHP array QUESTION?? HELP !

jamesharry404

Neues Mitglied
Good Morning Friends
I need some Help in php!
I was read all the tutorials of php array but i can't understand array so Please Help me!

There is some QUESTION please give me correct answer of these.

  • What is ARRAY?
  • Why we use ARRAY?
  • How a ARRAY works?
  • Why we use array?
  • Please tell me the work of array with a EXAMPLE also.
I am Waiting for the reply of that post
 
A Array is a bunch of values between one variable.

You could do

Code:
$var1 = '';
$var2 = '';
$var3 = '';
..

or

you can do

Code:
$vars = array(
     'keyName1' => 'val1',
     'keyName2' => 'val2',
     'keyName3' => 'val3',
     'whatever' => 'niceOne'
);

echo $vars[ 'keyName3' ]. ' ---'.$vars[ 'whatever' ];

// Output: 
// val3 ---niceOne

You also can iterate an array like

Code:
foreach( $vars as $val ){
   echo $val.'<br>';
}

// Output:
/*
*  val1
*  val2
*  val3
*  niceOne
*/

or

Code:
foreach( $vars as $key => $val ){
   echo 'Key: '.$key.' - Val: '.$val.'<br>';
}

// Output:
/*
*  Key: keyName1 - Val: val1
*  Key: keyName2 - Val: val2
*  ..
*  ..
*/

It's used as kind of a list.
 
Zurück
Oben