日期:2014-05-17 浏览次数:20761 次
$array = array('1 23 234', '2 24 235', '3 24 235', '4 25 235', '5 25 235', '6 37 456', '7 37 456'); $newArray = array(); foreach ($array as $value) { preg_match('/^[0-9]+\s([0-9]+\s[0-9]+$)/', $value, $mArray); $newArray[] = $mArray[1]; } $countArray = array_count_values($newArray); $fixArray = array(); $i = 1; foreach ($newArray as $newkey => &$value) { $newArrayKey = array(); if (array_key_exists($value, array_flip($newArray))) { $newArrayKey = array_keys($newArray, $value); if (count($newArrayKey) !== 1) { $tmp = array_search($newkey, $newArrayKey); $tmp = intval($tmp) + 1; $fixArray[] = $i . ' ' . $value . '-' . $tmp . '/' . $countArray[$value]; } else { $fixArray[] = $i . ' ' . $value; } $i++; } } print_r($fixArray);
------解决方案--------------------
妞妞,哪有事情做到一半的到底。起码也要注释解释一下吧。。
话说大版已好久没现身了。挺想念的。。