PHP : Shuffle an array

In this tutorial learn how to rearrange array or Shuffle an array in php.


function shufflearray($array)
    {
        shuffle($array);

        return $array;
    }

TUTORIAL

<?php

$array = Array
(
    'user_id' => 10,
    'id' => 2,
    'user' => 'Nakiya',

);
       /**
     * Shuffle an array.
     */
   function shufflearray($array)
    {
        shuffle($array);

        return $array;
    }


var_dump(shufflearray($array));
OUTPUT : DEMO

array(3) {
  [0]=>
  string(6) "Nakiya"
  [1]=>
  int(10)
  [2]=>
  int(2)
}

No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...