Cooly Wizardy Cooly Wizardy - 2 months ago 9
PHP Question

What are Arrays in PHP

As per standard Array definition: An array is a variable which allows you to store multiple value of same Data Type.

In PHP, say

$a=array("abc",123,"4");


What will be $a[0]
abc
, $a[1]
123
and $a[2]
4
treated as String, Numeric value or character value and Why?

flo flo
Answer

Arrays in PHP are different, there's only one type of array which an store different types. in Your example the items keep their original type. abc is a String, 123 is a number and 4 is a string.

You can even have nonnumeric keys. For Example $a["a"] = "test".

Comments