BB code: [code]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hmm, lets try the simpler approach:

Code: Select all

<?php

if(preg_match_all['#\['.'php](.*?)\[/'.'php]#is', $r['eksart'],$matches))
{
  foreach($matches[0] as $k => $str)
    $r['eksart'] = str_replace($str, '<b>PHP:</b><br><table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color: #FAFAFA; border: 1px solid #D1D7DC;">
  <tr>
    <td style="padding-left: 10px; padding-right: 10px; padding-top: 10px; padding-bottom: 10px;">' . highlight_string($matches[1][$k],true) .  '</td>
  </tr>
</table>');
}

?>
now, it kinda looks like we'll need a stripslashes in there, but not too sure..
Lundern
Forum Newbie
Posts: 8
Joined: Fri Aug 13, 2004 2:24 am

Post by Lundern »

Yes!!! Finally we got it to work :D There was some bugs though:

Code: Select all

if(preg_match_all('#\['.'php](.*?)\[/'.'php]#is', $r['eksart'],$matches)) 
{ 
  foreach($matches[0] as $k => $str) 
    $r['eksart'] = str_replace($str, '<b>PHP:</b><br><table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color: #FAFAFA; border: 1px solid #D1D7DC;"> 
  <tr> 
    <td style="padding-left: 10px; padding-right: 10px; padding-top: 10px; padding-bottom: 10px;">' . highlight_string($matches[1][$k],true) .  '</td> 
  </tr> 
</table>', $str); 
}
Thanks alot dude ;) Your link is on our page :)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

If you were using PEAR:HTML_BBCode you could have used http://home.mysth.be/~timvw/programming ... source.txt
Post Reply