3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ids = [1,2,3,4,5,6,7,8,9,10]; function createMultipleFromArticles($productsId): array { // It can be possible to have multiple product in the same page $productsId = array_unique($productsId); $positions = array_flip($productsId); $products = [1,4,6,7,9,10,2,3,5,8]; $products = array_combine($productsId, $products); var_export($products); return array_map(function (int $productId) use ($products, $positions) { return [$products[$productId], $positions[$productId] + 1]; // return $this->create($products[$productId], $positions[$productId] + 1); }, $productsId); } var_export(createMultipleFromArticles($ids));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 1 => 1, 2 => 4, 3 => 6, 4 => 7, 5 => 9, 6 => 10, 7 => 2, 8 => 3, 9 => 5, 10 => 8, )array ( 0 => array ( 0 => 1, 1 => 1, ), 1 => array ( 0 => 4, 1 => 2, ), 2 => array ( 0 => 6, 1 => 3, ), 3 => array ( 0 => 7, 1 => 4, ), 4 => array ( 0 => 9, 1 => 5, ), 5 => array ( 0 => 10, 1 => 6, ), 6 => array ( 0 => 2, 1 => 7, ), 7 => array ( 0 => 3, 1 => 8, ), 8 => array ( 0 => 5, 1 => 9, ), 9 => array ( 0 => 8, 1 => 10, ), )

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:
62.56 ms | 402 KiB | 8 Q