Замяна на BBCode с HTML

our

Registered
Значи искарвам си последните новини от сайта, но като има картинка
Код:
[img] [/img]
Html-а не приемя явно тоя таг и го изкарва нещо от сорта на :
Код:
[img:2421535] [/img]
Явно трябва да се заменят таговете ... Нещо такова ли трябва да стане :

Код:
str_replace ("[img]","<img src="",$post_text);
str_replace("[/img]","">",$post_text);

итн .. Или има някакъв по-лесен начин ... :)
 
Предполагам нещо от тоя род трябва да е но не съм сигурен :

("/(\[img\])(.+?)(\[\/img\])/i", '<img src="\\2">');
 
Код:
$post_text=str_replace("[img]",'<img src= ',$post_text);
$post_text=str_replace("[/img]",'>',$post_text);

Ето така трябва да е.
Имаше май грешно ползване на кавички в твоя пример.
ПРобвай и кажи дали всичко е наред.
 
Ами нали тага е
<img src="pic.jpg"
Аз бях включил и тея кавички :) както и да е де - не стана ...
 
our каза:
Ами нали тага е
<img src="pic.jpg"
Аз бях включил и тея кавички :) както и да е де - не стана ...

НЕ може да не става.
Дай да видя какво грешка ти дава.
Дай линк с пример какво дава.
Така на сляпо малко ми е трудно.
 
ЕДИТ:

Ето кой скрипт ползвам вече. Напълно идеален :

Код:
<html> 

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> 
</head> 

<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"> 
<body bgcolor="#000000"> 
<p><?php 

############# 
## Edit Below 
############# 

// Where to take the topics from 
// Always a number 
$forum = ''; 

// How many topics to show 
$limit = ''; 

// How to show the topics 
// full or blank ('') 
$show = 'full'; 

// How to display the date and time if used 
// short or long 
$date_time = 'short'; 

// How top display the topic link if usede 
// topic or phpbb 
$topic_link = 'topic'; 

// Comments link - how to send them to comments 
// topic or reply 
$comment = 'topic'; 

// Path to your forums directory 
// Usually ./forum/ or ./phpBB/ or ./forums/ 
$phpbb_root_path = ''; 

############################################# 
## No Editing unless you know what your doing 
############################################# 
if ( !defined('IN_PHPBB') ) 
{ 
  define('IN_PHPBB', true); 
  include($phpbb_root_path  . 'extension.inc'); 
  include($phpbb_root_path  . 'common.'.$phpEx); 
  include($phpbb_root_path  . 'config.'.$phpEx); 
} 

if ($show == '' || $show == 'full') 
{ 
   // Select the topic information from the correct forum and set it to $grab_topics 
   $grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' ORDER BY `topic_id` DESC LIMIT {$limit}"); 
} 

else if ($show == 'topic') 
{ 
   $grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$_GET['t']}' ORDER BY `topic_id` DESC"); 
} 
    
// Grab the information using an array and set it to $echo_topic 
while ($echo_topic = $db->sql_fetchrow($grab_topics)) 
{ 
   // Select the post information from the correct forum and set it to $grab_posts 
   $grab_posts = $db->sql_query("SELECT * FROM `{$table_prefix}posts` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$echo_topic['topic_id']}' LIMIT 1"); 
    
   // Grab the information using an array and set it to $echo_post 
   while ($echo_post = $db->sql_fetchrow($grab_posts)) 
   { 
      // Now get the post_text using the post_id were looking at and sort it info $grab_posts_text 
      $grab_posts_text = $db->sql_query("SELECT * FROM `{$table_prefix}posts_text` WHERE `post_id` = '{$echo_post['post_id']}'"); 
       
      // Grab the information using an array and set it to $echo_text 
      while($echo_text = $db->sql_fetchrow($grab_posts_text)) 
      { 
         // Find the user the posted 
         $find_user = $db->sql_query("SELECT * FROM `{$table_prefix}users` WHERE `user_id` = '{$echo_post['poster_id']}'"); 
          
         // Sort this users info into array for the post 
         while ($echo_user = $db->sql_fetchrow($find_user)) 
         { 
                
            // Get rid of all those annoying characters from bbcode 
            $echo_text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $echo_text);    
             
            // BBCode 
            $echo_text = str_replace("[b]","<strong>",$echo_text); 
            $echo_text = str_replace("[/b]","</strong>",$echo_text); 
                
            $echo_text = str_replace("[i]","<em>",$echo_text); 
            $echo_text = str_replace("[/i]","</em>",$echo_text); 
                
            $echo_text = str_replace("[u]","<u>",$echo_text); 
            $echo_text = str_replace("[/u]","</u>",$echo_text); 
                
            $echo_text = preg_replace('/\[quote="(.*)\"](.*)\[\/quote\]/Usi','<div style=\"Verdana: 7px\">$2</div>',$echo_text); 
             
            $echo_text = str_replace("[quote]","<strong>Quote</strong><em>",$echo_text); 
            $echo_text = str_replace("[/quote]","</em>",$echo_text); 
                
            $echo_text = str_replace("[code]","<strong>Code</strong><em>",$echo_text); 
            $echo_text = str_replace("
","</em>",$echo_text);

$echo_text = preg_replace('/\[list\](.*)\[\/list\]/si',"<div style=\"Verdana: 7px\">$1</div>",$echo_text);
$echo_text = preg_replace('/\
 
Написах скрипта но щом си имаш вече добре.
По-принцип се прави следното:
Питаш...
После някой се опитва да ти отговори...
И накрая ако си намерил решение не е зле да го покажеш защото някой
може да му потрябва.
Последните отговори за мен са спам.

не му мисли дадах му друг скрипт

Ае мишка аз сам си го намерих

Да наистина сложих си друг скрипт
http://bgnet.mygbgweb.com ...


Просто ми се разваля желанието да се мъча над нещо, което не ми трябва лично на мен.
НЕ виждам причина този код да е тайна.

Моето предложение е следното:

Код:
$post_text= preg_replace("/\[img(.*)\]/i","<a href=", $post_text); 
$post_text=str_replace("[/img]",'>',$post_text);
 
в случая и това трябва да работи :
Код:
$echo_text = str_replace("[img]","<img src=\"",$echo_text);
            $echo_text = str_replace("[/img]","\" alt=\"image\" />",$echo_text);
 

Горе