<?php
$arr = array(
array("url" => "http://google.com", "priority" => 2),
array("url" => "http://facebook.com", "priority" => 2),
array("url" => "http://youtube.com", "priority" => 2),
array("url" => "http://stackoverflow.com", "priority" => 1),
array("url" => "http://kickass.to", "priority" => 1),
array("url" => "http://twitter.com", "priority" => 1),
array("url" => "http://example.com", "priority" => 1),
);
// Recreate another array where we have multiple occurence of the same value (nb_of_occurence = priority)
$listOfUrl = array();
foreach ($arr as $url) {
$nbOfOccurence = $url['priority'];
for($i = 0 ; $i < $nbOfOccurence ; $i++) {
$listOfUrl[] = $url['url'];
}
}
echo '<pre>';
die(print_r($listOfUrl));
preferences:
44.98 ms | 402 KiB | 5 Q