Jump to content

[SOLVED] Functions


supanoob

Recommended Posts

ok so ima having abit of trouble with functions i have 2 functions 1 to change 1 set of strings into another and another one to reverse the process. now the first one works fine its the reversal that doesnt work. Below is a copy of both functions. the first one reverses a textarea input and the second one is meant to reverse the data in my $about_me field in the database.

 

Function 1 - Reversing the textarea:

<?php

function account ($account) { $account=htmlspecialchars($account); $account=str_replace (array('[', ']', 'url=', '/url', 'img=', 'post id=', '/post', 'font=', '/font', 'left', '/left', 'center', '/center', 'right', '/right', '', '', ':scared:', '', ':roll:', ':mad:', ':love:', '', ':S'), array('<', '>', 'a href=link_out.php?link=', '/a', 'img src=', 'a href=view_post.php?post_id=', '/a', 'font color=', '/font', 'p align=\"left\"', '/p', 'p align=\"center\"', '/p', 'p align=\"right\"', '/p', '<img src=\"/images/forum/wink.gif\">', '<img src=\"/images/forum/tongue.gif\">', '<img src=\"/images/forum/scared.gif\">', '<img src=\"/images/forum/sad.gif\">', '<img src=\"/images/forum/roll.gif\">', '<img src=\"/images/forum/mad.gif\">', '<img src=\"/images/forum/love.gif\">', '<img src=\"/images/forum/happy.gif\">', '<img src=\"/images/forum/confused.gif\">'), $account); return nl2br($account); }

?>

 

Function 2 - Reversing Function 1

 

<?php

function account_reverse ($about_me) { $about_me=htmlspecialchars($about_me); $about_me=str_replace (array('<', '>', 'a href=link_out.php?link=', '/a', 'img src=', 'a href=view_post.php?post_id=', '/a', 'font color=', '/font', 'p align=\"left\"', '/p', 'p align=\"center\"', '/p', 'p align=\"right\"', '/p', '<img src=\"/images/forum/wink.gif\">', '<img src=\"/images/forum/tongue.gif\">', '<img src=\"/images/forum/scared.gif\">', '<img src=\"/images/forum/sad.gif\">', '<img src=\"/images/forum/roll.gif\">', '<img src=\"/images/forum/mad.gif\">', '<img src=\"/images/forum/love.gif\">', '<img src=\"/images/forum/happy.gif\">', '<img src=\"/images/forum/confused.gif\">'), array('[', ']', 'url=', '/url', 'img=', 'post id=', '/post', 'font=', '/font', 'left', '/left', 'center', '/center', 'right', '/right', '', '', ':scared:', '', ':roll:', ':mad:', ':love:', '', ':S'), $about_me); return nl2br($about_me); }

?>

 

i have tried changing the $about_me to the textarea name and that didnt work.

Link to comment
https://forums.phpfreaks.com/topic/57113-solved-functions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.