저는 ob_start를 처음 사용하고 있습니다.이 함수가 붙어 있습니다!ob_start "함수 동결"매개 변수
텍스트에서 일부 태그를 구문 분석하고 함수에서 다른 텍스트 리턴 세트로 바꿔야했습니다.
http://codepad.viper-7.com/SjKqS1
<html>
<body>
<?php
$data = <<<EOF
LAST_NAME : 문제는, 내가 쉘의 코드를 게시 ... 내가위한 ob_start 호출 할 때, 수행 기능을 모든 sequentials에 대한 첫 번째 매개 변수가 전화를 유지 나의 설명에 대한 유감입니다 , FIRST_NAME [시험 명 = 12] 칼 다시 김 수은 [시험 명 = 3] dsdss dsddsdsds sabanana dsdsdsds [시험 명 = "ABCDEFG"] frickenoich EOF;
$tag = 'test';
$re = "/\\[". $tag ."[\\]| ]/m";
preg_match_all($re, $data, $match);
$re = "/\[" . $tag . " (.*)\=([\"|\'|[:alnum:]]*)]/m";
$count = preg_match_all($re, $data, $match, PREG_SET_ORDER);
for($i = 0; $i < $count; $i++) {
$count_args = count($match[ $i ]);
$args = array();
// if any argouments, make an argouments array
if($count_args) {
// make array of argouments
for($arg_idx = 1; $arg_idx < $count_args; $arg_idx += 2){
$args[ $match[ $i ][ $arg_idx ] ] = $match[ $i ][ $arg_idx + 1 ];
}
}
echo 'name='.$args['name'];
echo '<br>';
ob_start();
call_user_func('test', $args);
$ret_func = ob_get_clean();
$data = preg_replace($re, $ret_func, $data);
}
function test($arg) {
echo '<br>test(' . $arg['name'] . ')<br>';
}
?>
</body>