PHP array efficiency and scalability

When declaring an array in PHP, the index may not be created in order ... Ie

Array [1] = 1 Array [19] = 2 Array [4] = 3

My question is. When creating an array like this, is length 19 with zeros in between? If I tried to get Array [3], would it come as undefined or throw an error? Also, how does this affect memory. Will memory with index 3 be busy or 19?

Also, the developer is currently writing a script with 3 arrays FailedUpdates [] FailedDeletes [] FailedInserts []

How much more efficient is it to do this, or to do it in the case of an associative array managing multiple submatrices

"Failures" array(){
    ["Updates"] => array(){
           [0] => 12
           [1] => 41
                   }
    ["Deletes"] => array(){
           [0] => 122
           [1] => 414
           [1] => 43
                   }
    ["Inserts"] => array(){
           [0] => 12
                   }
}
+3
source share
3

- , PHP, / .

PHP ++ ; PHP - . ( ) , . , :

array(0 => 'butt', 1 => 'potato', 2 => 'tulip')

array(5 => 'i', 'barry' => 6, 19 => array(-1 => array(), 7 => 'smock'))

3 , 3 3 .

, /. , , . , foreach().

+4

array [3] undefined/unset, , 3 - php C, .

+1
  • $arr [3] : Notice: Undefined offset: 3 in /data/home/sjoerd/public_html/svnreps/test/a.php on line 3. , isset() array_key_exists().
  • .
  • .
  • , , .
+1

Source: https://habr.com/ru/post/1749939/


All Articles