
22-10-2005, 12:08
|
|
|
|
חבר מתאריך: 03.01.05
הודעות: 840
|
|
|
BBCODE...
קוד PHP:
<?php
function php($string) { $match_count = preg_match_all( '#\[php\](.*?)\[\/php\]#si', $string, $matches); for( $i = 0; $i < $match_count; $i++ ) { $after_replace = $matches[1][$i]; $after_replace = highlight_string( htmlspecialchars2( nl2br2( $after_replace ) ), TRUE ); $after_replace = str_replace( ' ', ' ', $after_replace ); $after_replace = str_replace( ' ', ' ', $after_replace ); $after_replace = str_replace( "\t", ' ', $after_replace ); return $after_replace; } } function nl2br2( $text ) { return str_replace( '<br />', '', $text ); } function htmlspecialchars2( $text ) { static $patterns, $replaces; if( !$patterns ){ $patterns = array( '#<#', '#>#', '#&#', '#"#' ); $replaces = array( '<', '>', '&', '"' ); } return preg_replace( $patterns, $replaces, $text ); } $string = "bla bla bla...[php]<?php echo('Hello'); ?>[//php]<br />bla bla..."; // בכוונה זה שתי / כי זה יסגור.. echo php($string); ?>
יש לי את הכל הזה מה שהוא עושה זה לקחת את מה שבין התגיות של ה [php] אבל הבעיה היא שאני רוצה שהפט יהיה עם כל המשתנה ולא רק את מה שיש בין התגיות... איך עושים את זה?
|