iv got a question in php regex. For example if we use
<?php
$str = '[code]anything[/code]';
preg_replace('#\[code\](.*?)\[/code\]#is', 'Code:<pre>$1</pre>', $str)
?>
How i can make some thing like this to count the content
<?php
$str = '[code]anything[/code]';
preg_replace('#\[code\](.*?)\[/code\]#is', 'Code:'.strlen($1).'<pre>$1</pre>', $str)
?>
and that is my question. hope i will find answer thanks.
How about:
<?php
$str = '[code]anything[/code]';
$code = preg_replace('#\[code\](.*?)\[/code\]#is', '$1', $str);
$output = 'Code:'.strlen($code).'<pre>'.$code.'</pre>';
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.