Magento Engineer
social
Journal

Difference b/w Numeric Array and Associative Array?

Numeric Array:
These arrays can store numbers, strings and any object but their index will be represented by numbers.
By default array index starts from zero.

<?php
         /* First method to create array. */
         $numbers = array( 1, 2, 3);
         
         foreach( $numbers as $value ) {
            echo "Value is $value <br />";
         }
?>

Associative Arrays:

The associative arrays are very similar to Numeric arrays in term of functionality but they are different in terms of their index.
Associative array will have their index as string so that you can establish a strong association between key and values.

$numbers = array( "a"=>1, "b"=>2, "c"=>3);

Ad comes here
Comments
Leave A Comment
PHP blog
Update Cookies Preferences