Top > diary > 2007-07-02

***そういえば [#t13ebbcd]
 土曜日に、tableデータの処理をするときのプログラムを作っていたのだが、内容は、処理する領域を全体、または指定列に対して行えるように定義されたオプションを読み取って実行するものだ。~
//cut
~
 そして下記のようなものを作ってみたのだが…

#geshi{{{
$count = count($line_data);
$option_c = ($option_a && !isset($option_b))? array_fill(0, $count, 1): array_fill(0, $count, 0);
if ( strpos($option_b, ',') === FALSE ) {
	$option_c[$option_b] = 1;
} else {
	$m =explode(',', $option_b);
	foreach ($m as $m_line) {
		$option_c[$m_line] = 1;
	}
}
for ( $x = 0 ;$x <= $count ; $x++){
	if ( $option_c[$x] )
		処理($line_data[$x]);
}
}}}

 そういえば以前にも似たようなものを作ったと思い出して調べてみると
#geshi{{{
$all = (isset($option_a) && !isset($option_b)) ? 1 : 0;
$count = count($line_data);
if ( strpos($option_b, ',') === FALSE ) {
	$option_c[] = $option_b;
} else {
	$option_c =explode(',', $option_b);
}
for ( $x = 0 ;$x <= $count ; $x++){
	if ( array_search($x, $option_c) !== false || $all)
		処理($line_data[$x]);
}
}}}
~
(; ゚ Д ゚)

#geshi{{{
for ( $x = 0 ;$x <= $count ; $x++){
	if ( in_array($x, $option_c) || $all)
		処理($line_data[$x]);
}
}}}

こうするべきだね…orz


リロード   新規 下位ページ作成 編集 凍結 差分 添付 コピー 名前変更   ホーム 一覧 検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS