TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-04-2008, 03:18 PM   #1 (permalink)
The Contributor
 
Evulness's Avatar
 
Join Date: Apr 2008
Location: Tampa, FL
Posts: 65
Thanks: 6
Evulness is on a distinguished road
Default pregreplace & minor bbcoding

Ok, heres my deal.

Code:
echo '<tr align="center">';
foreach ($row as $key => $value) {
    if ($key == "id"){
    echo '<td bgcolor="'.$bg.'" ><a href="index.php?page=edit&id='.$value.'">'.$value.'</a></td>';
    }else{
        if ($key == "comment"){
            echo '<td bgcolor="'.$bg.'" width="25%" >'.$value.'</td>';}
                     else{echo '<td bgcolor="'.$bg.'" >'.$value.'</td>';
         }
    }
  }
    echo "</tr>";
query for above code
Quote:
sql ="SELECT id, username, email, first_name, last_name, nonprofit_date, packet1, packet2, comment
FROM users
WHERE level=1
ORDER by ".$order." ".$dir."
LIMIT ".$limit."
";
when i do this, my comment cell is a bunch of comments. each seperate comment is surrounded like bbcode [my comment1] [mycomment2]

what i need to do is take this part:
Code:
if ($key == "comment"){
            echo '<td bgcolor="'.$bg.'" width="25%" >'.$value.'</td>';}
                     else{echo '<td bgcolor="'.$bg.'" >'.$value.'</td>';
         }
and i need to parse out that indevidual if() statement, and make it parts out each [] and put it on a seperate line. i know i need to use a preg_replace. but preg_replace is so forigne to me... i can't figure out how to get it to work.

any suggestions?
__________________
"Knowledge is power. Abuse it."~Evulness
My portfolio: www.evularts.com
Send a message via AIM to Evulness
Evulness is offline  
Reply With Quote
Old 08-04-2008, 03:22 PM   #2 (permalink)
The Contributor
 
Evulness's Avatar
 
Join Date: Apr 2008
Location: Tampa, FL
Posts: 65
Thanks: 6
Evulness is on a distinguished road
Default

oh. and if i can begin each comment with an asterisk * so my $value for $comment would be something like this....

$comment = "*unpaid amount due. *need to re-send fax sheet";
__________________
"Knowledge is power. Abuse it."~Evulness
My portfolio: www.evularts.com
Send a message via AIM to Evulness
Evulness is offline  
Reply With Quote
Old 08-04-2008, 03:32 PM   #3 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

This should get you started.

p.s. im not the best at regex so im sure there is a quicker way.

PHP Code:
$string '[bold]this will be turned bold hopefully[/bold]';
echo 
preg_replace('/\[bold\](.*)\[\/bold\]/is''<b>\\1</b>'$string); 
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)

Last edited by sketchMedia : 08-04-2008 at 03:45 PM. Reason: added s modifier so it matches blocks across new lines
sketchMedia is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:05 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design