Jump to content

Array shuffle with step


silkfire

Recommended Posts

How does one create a function that shuffles a numerical array X amount of steps?

 

Example:

 

$array = array('item1', 'item2', 'item3', 'item4');

 

$array = array_shuffle($array, 2);

 

Result should be:

array('item3', 'item4', 'item1', 'item2')

 

Function looks like: array_shuffle($array, $steps, $direction = 1);

 

$direction is 1 for forward or 0 for backwards.

 

Is this hard?

Link to comment
https://forums.phpfreaks.com/topic/243506-array-shuffle-with-step/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.