Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Tutorials > PHP Tutorials

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

PHP Tutorials PHP Tutorials

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-2007, 10:16 AM
Jaan's Avatar   
Jaan Jaan is offline
<img src="http://forum.codecall.net/images/userbar/mod.png" alt="Mod">
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 887
Last Blog:
Wadio Media Layout Com...
Credits: 56
Rep Power: 15
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default Show smileys using str_replace()

Well it's really simple trick..

(you can copy those smileys)
smile.gif
laugh.gif
sad.gif

PHP Code:
<?php

// Display your form
function form(){

echo 
"<form action='?act=show' method='post'>"
    
."<textarea name='text' cols='50' rows='10'></textarea><br>"
    
."<input type='submit' value='Show'>"
    
."</form>";
    
}

function 
show(){

// Request your text
$text $_REQUEST['text'];

// This will determine things what you want to replace
$replace = array(":)"":D"":(");

// This will determine your text replacement
$replace_to = array("<img src='smile.gif'>""<img src='laugh.gif'>""<img src='sad.gif'>");
$content str_replace($replace$replace_to$text);

// Show your text with smileys
echo $content;

}

switch(
$act){

default;
form();
break;

case 
"show";
show();
break;

}

?>
Example
__________________


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
| Need help? Send a
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


Last edited by Jaan; 02-09-2007 at 05:12 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 02-08-2007, 07:44 PM
justin justin is offline
Learning Programmer
 
Join Date: Jan 2007
Posts: 43
Credits: 0
Rep Power: 7
justin is on a distinguished road
Default

PHP Code:
// This will determine things what you want to replace
$replace = array(":)"":D"":(");

// This will determine your text replacement
$replace_to = array("<img src='smile.gif'>""<img src='laugh.gif'>""<img src='sad.gif'>");
$content str_replace($replace$replaceto$text); 
With the str_replace when you use the $replaceto variable, shouldn't it be $replace_to, like the variables name?
__________________

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.

I am currently willing to do just about anything for $50 on paypal, anyone need odd jobs done?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-09-2007, 05:13 AM
Jaan's Avatar   
Jaan Jaan is offline
<img src="http://forum.codecall.net/images/userbar/mod.png" alt="Mod">
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 887
Last Blog:
Wadio Media Layout Com...
Credits: 56
Rep Power: 15
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default

oops.. my bad oki i fixed it.. thanks
__________________


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
| Need help? Send a
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-09-2007, 12:21 PM
justin justin is offline
Learning Programmer
 
Join Date: Jan 2007
Posts: 43
Credits: 0
Rep Power: 7
justin is on a distinguished road
Default

Just thought you might like to know
__________________

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.

I am currently willing to do just about anything for $50 on paypal, anyone need odd jobs done?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to show Hidden Files in Computer! Onur Tutorials 0 08-28-2007 05:24 AM
[Solved] yes/no box missing show release date rolandd ionFiles 4 07-26-2007 12:44 PM
Can someone show me a very simple way thesquirrel16 Database & Database Programming 6 04-23-2007 07:04 AM
Who can show me how to do this program? Sharp Java Help 7 10-12-2006 04:35 PM
Favorite Show on TV NeedHelp The Lounge 24 08-17-2006 10:15 PM


All times are GMT -5. The time now is 11:35 PM.

Contest Stats

Xav ........ 1276.19
MeTh0Dz|Reb0rn ........ 1048.58
marwex89 ........ 869.98
John ........ 868.39
morefood2001 ........ 868.04
WingedPanther ........ 761.06
Brandon W ........ 684.87
chili5 ........ 294.12
Steve.L ........ 216.18
dargueta ........ 192.86

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 81%

Ads