Jump to content
php.lv forumi

array, code tags


chizijs

Recommended Posts

Kā uztaisīt, lai kodu radītu, ja viņš tekstā ir rakstīts šādi

Mans 1. kods :O

[.code]<?php echo ""; ?>[/code]

Mans kods

<?php
ob_start();
       $teksts=htmlspecialchars($tem['teksts']);
       $get=array(
       "/\[code\](.*?)\[\/code\]/"
       );
       $replace=array(
       "".printCode('$1', 1).""
       );
       $teksts = preg_replace($get,$replace,$teksts);
echo $teksts;
?>

Un iznākumā man radā šādi

Man nav koda

(

 stils) $1

Tātad radā $1 ja nav nekāda [code] taga??

Link to comment
Share on other sites

Un, ja man tur netikai [.code], bet , tagi? Tad arī var izmantot preg_replace_callback ?

kaut ka šādi esmu uzlicis, bet nekā ^^

$teksts=preg_replace_callback("/\[code\](.*?)[\/code\]", printCode($teksts2,1), $teksts2);

Edited by chizijs
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...