3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = [1, 2, 3, 4, 5]; $vendors = ["Amazon", "Newegg", "Frys"]; $combinations = array(''); function pc_permute($items, $perms = array()) { if (empty($items)) { echo join(' ', $perms) . "</br>"; //return $perms; //array_push($combinations, $perms); } else { for ($i = count($items) - 1; $i >= 0; --$i) { $newitems = $items; $newperms = $perms; list($foo) = array_splice($newitems, $i, 1); array_unshift($newperms, $foo); pc_permute($newitems, $newperms); } } } pc_permute($products); var_dump($combinations);
Output for git.master, git.master_jit, rfc.property-hooks
1 2 3 4 5</br>2 1 3 4 5</br>1 3 2 4 5</br>3 1 2 4 5</br>2 3 1 4 5</br>3 2 1 4 5</br>1 2 4 3 5</br>2 1 4 3 5</br>1 4 2 3 5</br>4 1 2 3 5</br>2 4 1 3 5</br>4 2 1 3 5</br>1 3 4 2 5</br>3 1 4 2 5</br>1 4 3 2 5</br>4 1 3 2 5</br>3 4 1 2 5</br>4 3 1 2 5</br>2 3 4 1 5</br>3 2 4 1 5</br>2 4 3 1 5</br>4 2 3 1 5</br>3 4 2 1 5</br>4 3 2 1 5</br>1 2 3 5 4</br>2 1 3 5 4</br>1 3 2 5 4</br>3 1 2 5 4</br>2 3 1 5 4</br>3 2 1 5 4</br>1 2 5 3 4</br>2 1 5 3 4</br>1 5 2 3 4</br>5 1 2 3 4</br>2 5 1 3 4</br>5 2 1 3 4</br>1 3 5 2 4</br>3 1 5 2 4</br>1 5 3 2 4</br>5 1 3 2 4</br>3 5 1 2 4</br>5 3 1 2 4</br>2 3 5 1 4</br>3 2 5 1 4</br>2 5 3 1 4</br>5 2 3 1 4</br>3 5 2 1 4</br>5 3 2 1 4</br>1 2 4 5 3</br>2 1 4 5 3</br>1 4 2 5 3</br>4 1 2 5 3</br>2 4 1 5 3</br>4 2 1 5 3</br>1 2 5 4 3</br>2 1 5 4 3</br>1 5 2 4 3</br>5 1 2 4 3</br>2 5 1 4 3</br>5 2 1 4 3</br>1 4 5 2 3</br>4 1 5 2 3</br>1 5 4 2 3</br>5 1 4 2 3</br>4 5 1 2 3</br>5 4 1 2 3</br>2 4 5 1 3</br>4 2 5 1 3</br>2 5 4 1 3</br>5 2 4 1 3</br>4 5 2 1 3</br>5 4 2 1 3</br>1 3 4 5 2</br>3 1 4 5 2</br>1 4 3 5 2</br>4 1 3 5 2</br>3 4 1 5 2</br>4 3 1 5 2</br>1 3 5 4 2</br>3 1 5 4 2</br>1 5 3 4 2</br>5 1 3 4 2</br>3 5 1 4 2</br>5 3 1 4 2</br>1 4 5 3 2</br>4 1 5 3 2</br>1 5 4 3 2</br>5 1 4 3 2</br>4 5 1 3 2</br>5 4 1 3 2</br>3 4 5 1 2</br>4 3 5 1 2</br>3 5 4 1 2</br>5 3 4 1 2</br>4 5 3 1 2</br>5 4 3 1 2</br>2 3 4 5 1</br>3 2 4 5 1</br>2 4 3 5 1</br>4 2 3 5 1</br>3 4 2 5 1</br>4 3 2 5 1</br>2 3 5 4 1</br>3 2 5 4 1</br>2 5 3 4 1</br>5 2 3 4 1</br>3 5 2 4 1</br>5 3 2 4 1</br>2 4 5 3 1</br>4 2 5 3 1</br>2 5 4 3 1</br>5 2 4 3 1</br>4 5 2 3 1</br>5 4 2 3 1</br>3 4 5 2 1</br>4 3 5 2 1</br>3 5 4 2 1</br>5 3 4 2 1</br>4 5 3 2 1</br>5 4 3 2 1</br>array(1) { [0]=> string(0) "" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.64 ms | 405 KiB | 8 Q