<?php
$html = "123123123[12345][00001][11111]12312312";
preg_match_all("|[\[](\d{5})[\]]|U", $html, $matches);
for ($i=0; $i< count($matches[0]); $i++) {
echo "matched: " . $matches[0][$i] . "\n";
echo "part 1: " . $matches[1][$i] . "\n\n";
$packs .= $matches[1][$i].",";
}
echo $packs;
?>
결과--------------------------------
matched: [12345]
part 1: 12345
matched: [00001]
part 1: 00001
matched: [11111]
part 1: 11111
샘플 2
<?
$string = "타입과색상;CMT0025댄디PK/블랙M(3000원)./(3000원)";
preg_match_all("|[\(](.*)[원\)]|U", $string, $matches);
for( $i=0; $i < count($matches[1]); $i++ )
{
$total = $total + $matches[1][0];
}
echo "total: $total\n";
?>
~
total: 6000
댓글 없음:
댓글 쓰기