$str = '2009.1|2009.2|2009.6|2009.6|2009.6|2009.7 |2009.8|2009.8|2009.9|2009.9|2009.9|2009.10|2009.10|2009.10|2009.10';
echo $str . '<br><br>';
$tab = explode('|', $str);
$tab2 = array_unique($tab);
echo '<pre>'; print_r($tab2); echo '</pre>';
$cnt = count($tab2);
for($i=0; $i<$cnt; $i++) {
echo $tab2[$i].' ';
}
echo '<br><br>';</p>
foreach($tab2 as $row) {
echo $row.' ';
}
Wyniki:
2009.1|2009.2|2009.6|2009.6|2009.6|2009.7 |2009.8|2009.8|2009.9|2009.9|2009.9|2009.10|2009.10|2009.10|2009.10
Array
(
[0] => 2009.1
[1] => 2009.2
[2] => 2009.6
[5] => 2009.7
[6] => 2009.8
[8] => 2009.9
[11] => 2009.10
)
for:
2009.1 2009.2 2009.6 2009.7 2009.8
foreach:
2009.1 2009.2 2009.6 2009.7 2009.8 2009.9 2009.10