', $res); } else { $res = str_replace($m[0][$i], '', $res); } } else { $temp = ''; for($j = 0; $j < $n; $j++) { if($c == $j + 1) { $temp .= ''; } else { $temp .= ''; } } $res = str_replace($m[0][$i], $temp, $res); } } return $res; } function get_repl($s, $db_f) { $res = $s; preg_match_all('#\[Get_([A-Za-z]+)_([A-Za-z]+)]#', $s, $m); for($i = 0; $i < count($m[0]); $i++) { $nam1 = $m[1][$i]; $nam2 = $m[2][$i]; $res = str_replace($m[0][$i], $db_f($nam1, $nam2), $res); } return $res; } function mulrepl($s, $chkbox_f, $radio_f, $db_f) { $res = $s; $res = calc_repl($res); $res = check_repl($res, $chkbox_f, $radio_f); $res = get_repl($res, $db_f); return $res; } function test($inpstr, $expoutpstr, $chkbox_f, $radio_f, $db_f) { $outpstr = mulrepl($inpstr, $chkbox_f, $radio_f, $db_f); echo "$expoutpstr\r\n"; echo "$outpstr\r\n"; } function chkbox_nam($count) { return 'cb' . $count; } function radio_nam($count) { return 'r' . $count; } function get_db($nam1, $nam2) { return '50%'; } test('[Calc:4+7] eller [Calc:7*17] måske [Calc:6/3]', '4+7=11 eller 7*17=119 måske 6/3=2', 'chkbox_nam', 'radio_nam', 'get_db'); test('Dette er en checkbox [Check*1]', 'Dette er en checkbox ', 'chkbox_nam', 'radio_nam', 'get_db'); test('Dette er en checkbox [Check*1=0]', 'Dette er en checkbox ', 'chkbox_nam', 'radio_nam', 'get_db'); test('Dette er en checkbox [Check*1=1]', 'Dette er en checkbox ', 'chkbox_nam', 'radio_nam', 'get_db'); test('Dette er radioboxe [Check*2]', 'Dette er radioboxe ', 'chkbox_nam', 'radio_nam', 'get_db'); test('Dette er radioboxe [Check*2=0]', 'Dette er radioboxe ', 'chkbox_nam', 'radio_nam', 'get_db'); test('Dette er radioboxe [Check*2=1]', 'Dette er radioboxe ', 'chkbox_nam', 'radio_nam', 'get_db'); test('Dette er flere radioboxe [Check*4]', 'Dette er flere radioboxe ', 'chkbox_nam', 'radio_nam', 'get_db'); test('Dette er en udlæst procent [Get_ramme_status] af gruppen status i db tabellen ramme', 'Dette er en udlæst procent 50% af gruppen status i db tabellen ramme', 'chkbox_nam', 'radio_nam', 'get_db'); test("[Check*1=0] - Test 1\r\n[Check*1=1] - Test 2", " - Test 1\r\n - Test 2", 'chkbox_nam', 'radio_nam', 'get_db'); ?>