How to add an element to another mass (multi-dimensional)



  • There is:

    $families = array(array("Tom", "Alice"), array("Bob", "Kate"));
    

    We need to add a set of elements to:

    $families = array(array("Tom", "Alice"), array("Bob", "Kate"), array("Alex", "Bob"));
    


  • We can use the function. https://www.php.net/manual/ru/function.array-push.php which adds one or more elements to the end of the mass.

    The same effect can be achieved:

    $arr[] = YOUR_CUSTOM_ARRAY
    

    I mean, to write the name of the mass where new data will be added, beyond square brackets and further attribution


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2