Home » PHP » PHP Arrays » Question
  1. What will be the output of the following PHP code?
    <?php
    $Flower = array("Daffodil", "Dahlia", "Daisy", "Daphne", "Delphinium", "Dianella");
    print_r(array_chunk($Flower, 3));
    ?>


    1. Array
      (
      [0] => Array
      (
      [0] => Daffodil
      [1] => Dahlia
      [2] => Daisy
      )
      )
    2. Array
      (
      [1] => Array
      (
      [0] => Daphne
      [1] => Delphinium
      [2] => Dianella
      )
      )
    3. Array
      (
      [0] => Array
      (
      [0] => Daffodil
      [1] => Dahlia
      [2] => Daisy
      )

      [1] => Array
      (
      [0] => Daphne
      [1] => Delphinium
      [2] => Dianella
      )
      )
    4. Array
      (
      [0] => Array
      (
      [0] => Daffodil
      [1] => Dahlia
      )

      [1] => Array
      (
      [0] => Daphne
      [1] => Delphinium
      )
      )
    5. None of these
Correct Option: C

The array_chunk() function splits an array into chunks of new arrays.



Your comments will be displayed only after manual approval.