我有一个数组,其中包含如下数据:
Array (
[0] => Array (
[www.google.com] => www.google.com/a
)
[1] => Array (
[www.google.com] => www.google.com/a
)
[2] => Array (
[www.test.com] => www.test.com
)
[5] => Array (
[www.test.com] => www.test.com/c
)
)
我需要像这样对特定网址的所有链接进行格式化:
Array (
[www.google.com] => Array (
[0] => www.google.com/a
[1] => www.google.com/a
)
[www.test.com] => Array (
[0] => www.test.com
[1] => www.test.com/c
)
)
请为此提供帮助吗?
答案 0 :(得分:3)
如果我们调用第一个数组$domains
。
$groups = array();
for ($i = 0; $i <= count($domains); $i++)
{
foreach ($domains[$i] as $domain => $url)
{
$groups[$domain][] = $url;
}
}
print_r($groups);
那可能有用......