php smilie code check |
Author: |
Message: |
Veggie
Full Member
Posts: 415 Reputation: 21
37 / /
Joined: Sep 2004
|
RE: php smilie code check
$text = "hello test ";
then string replace
then
echo $text;
|
|
12-24-2005 04:54 PM |
|
|
stoshrocket
Senior Member
formerly methos
Posts: 748 Reputation: 31
34 / /
Joined: Aug 2005
|
O.P. RE: php smilie code check
quote: Originally posted by Veggie
$text = "hello test ";
then string replace
then
echo $text;
ok, im well and truly baffled. i think it would be quicker with the <img src=".."> code... lol, thanks anyway!
This post was edited on 12-24-2005 at 05:06 PM by stoshrocket.
|
|
12-24-2005 05:06 PM |
|
|
Plik
Veteran Member
Posts: 1489 Reputation: 46
35 / / –
Joined: Jun 2004
|
RE: php smilie code check
quote: Originally posted by Methos2
quote: Originally posted by Veggie
$text = "hello test ";
then string replace
then
echo $text;
ok, im well and truly baffled. i think it would be quicker with the <img src=".."> code... lol, thanks anyway!
What he wants is for you to set $text to "hello test :[b][/b]o" then perform the replace and then echo $text and tell us what it outputs.
Also could you post your complete $smiley_list and $replacement_list, arrays? (the two limes that start with $smiley_list = Array, and $replacement_list = Array)
|
|
12-24-2005 05:11 PM |
|
|
hmaster
Senior Member
Posts: 716 Reputation: 24
33 / /
Joined: Nov 2004
|
RE: php smilie code check
He means that the code will only work if you put the text in the $text variable.
This is my news post 0:) :D :)
code: <?php
$text = "This is my news post 0:) :D :)[";
$smiley_list = array(":)", "0:)", ":D", the rest of the smilies);
$replacement_list = array('<img alt="smiley" src="smilies/grin.gif" />', '<img alt="smiley" src="smilies/angel.gif" />', '<img alt="smiley" src="smilies/biggrin.gif" />', The rest of the replacements here, using this format: '<img alt="alttext" src="location' />");
$text = str_replace($smiley_list, $replacement_list, $text);
echo $text;
?>
lol @Madman
This post was edited on 12-24-2005 at 05:18 PM by hmaster.
|
|
12-24-2005 05:12 PM |
|
|
stoshrocket
Senior Member
formerly methos
Posts: 748 Reputation: 31
34 / /
Joined: Aug 2005
|
O.P. RE: php smilie code check
quote: Originally posted by hmaster
He means that the code will only work if you put the text in the $text variable.
This is my news post 0:) :D :)
code: <?php
$text = "This is my news post 0:) :D :)[";
$smiley_list = array(":)", "0:)", ":D", the rest of the smilies);
$replacement_list = array('<img alt="smiley" src="smilies/grin.gif" />', '<img alt="smiley" src="smilies/angel.gif" />', '<img alt="smiley" src="smilies/biggrin.gif" />', The rest of the replacements here, using this format: '<img alt="alttext" src="location' />");
$text = str_replace($smiley_list, $replacement_list, $text);
echo $text;
?>
but having to to do this throughout the code deifes the object of a 'shortcut' such as :), unless i have missed something here it would be alot simpler and quicker to just use the html tag <img> wouldnt it....
This post was edited on 12-24-2005 at 07:59 PM by stoshrocket.
|
|
12-24-2005 07:58 PM |
|
|
hmaster
Senior Member
Posts: 716 Reputation: 24
33 / /
Joined: Nov 2004
|
RE: php smilie code check
In your case yes. But it depends how you do it.
Something like WordPress does not rely on FTP to add new blog/news posts. It has a form, which then can be easier to add scripts too.
|
|
12-24-2005 08:03 PM |
|
|
Plik
Veteran Member
Posts: 1489 Reputation: 46
35 / / –
Joined: Jun 2004
|
RE: php smilie code check
quote: Originally posted by Methos2
quote: Originally posted by hmaster
He means that the code will only work if you put the text in the $text variable.
This is my news post 0:) :D :)
code: <?php
$text = "This is my news post 0:) :D :)[";
$smiley_list = array(":)", "0:)", ":D", the rest of the smilies);
$replacement_list = array('<img alt="smiley" src="smilies/grin.gif" />', '<img alt="smiley" src="smilies/angel.gif" />', '<img alt="smiley" src="smilies/biggrin.gif" />', The rest of the replacements here, using this format: '<img alt="alttext" src="location' />");
$text = str_replace($smiley_list, $replacement_list, $text);
echo $text;
?>
but having to to do this throughout the code deifes the object of a 'shortcut' such as :), unless i have missed something here it would be alot simpler and quicker to just use the html tag <img> wouldnt it....
The whole point in that is to test that you are setting the $text variable correctly and that you are executing the function correctly, you wont have to do that for the code once whe can make sure that it is working correctly.
also:
quote: Originally posted by Madman
could you post your complete $smiley_list and $replacement_list, arrays? (the two limes that start with $smiley_list = Array, and $replacement_list = Array)
|
|
12-24-2005 08:15 PM |
|
|
stoshrocket
Senior Member
formerly methos
Posts: 748 Reputation: 31
34 / /
Joined: Aug 2005
|
O.P. RE: php smilie code check
ok, it shows as it should, it replaces the smilies with the appropriate pics, and as for the code, ill just go and fetch it.....
this is the whole php code that is in the document::
code: <?php
$smiley_list = array(":)", "0:)", ":D", ":S", "B)", ":'(", ":$",
":|", "8-)", "^o)", ":o", ":P", ";)", ":refuck:", ">(", "='(",
"=D", "O.o", "=(", "=)", "=P", "=/", );
$replacement_list = array(
'<img alt="smilie" src="smilies/grin.gif" />',
'<img alt="smilie" src="smilies/angel.gif" />',
'<img alt="smilie" src="smilies/biggrin.gif" />',
'<img alt="smilie" src="smilies/confuzzled.gif" />',
'<img alt="smilie" src="smilies/cool.gif" />',
'<img alt="smilie" src="smilies/cry.gif" />',
'<img alt="smilie" src="smilies/embarrassed.gif" />',
'<img alt="smilie" src="smilies/notamused.gif" />',
'<img alt="smilie" src="smilies/rolleyes.gif" />',
'<img alt="smilie" src="smilies/sarcastic.gif" />',
'<img alt="smilie" src="smilies/shock.gif" />',
'<img alt="smilie" src="smilies/tongue.gif" />',
'<img alt="smilie" src="smilies/wink.gif" />',
'<img alt="smilie" src="smilies/refuck.gif" />',
'<img alt="smilie" src="smilies/bangry.gif" />',
'<img alt="smilie" src="smilies/bcry.gif" />',
'<img alt="smilie" src="smilies/blaugh.gif" />',
'<img alt="smilie" src="smilies/bwassat.gif" />',
'<img alt="smilie" src="smilies/bsad.gif" />',
'<img alt="smilie" src="smilies/bsmile.gif" />',
'<img alt="smilie" src="smilies/btongue.gif" />',
'<img alt="smilie" src="smilies/bwink.gif" />',
);
$text = str_replace($smiley_list, $replacement_list, $text);
?>
This post was edited on 12-24-2005 at 08:19 PM by stoshrocket.
|
|
12-24-2005 08:18 PM |
|
|
Plik
Veteran Member
Posts: 1489 Reputation: 46
35 / / –
Joined: Jun 2004
|
RE: php smilie code check
quote: Originally posted by Methos2
ok, it shows as it should, it replaces the smilies with the appropriate pics, and as for the code, ill just go and fetch it.....
this is the whole php code that is in the document:
Then if it works as it should if you set the the $text variable in the script then the problem is caused by how you set the $text variable to your input.
|
|
12-24-2005 08:29 PM |
|
|
stoshrocket
Senior Member
formerly methos
Posts: 748 Reputation: 31
34 / /
Joined: Aug 2005
|
O.P. RE: php smilie code check
quote: Originally posted by Madman
quote: Originally posted by Methos2
ok, it shows as it should, it replaces the smilies with the appropriate pics, and as for the code, ill just go and fetch it.....
this is the whole php code that is in the document:
Then if it works as it should if you set the the $text variable in the script then the problem is caused by how you set the $text variable to your input.
its not a case of it not working.... its just a case of that...
quote: Originally posted by Methos2
but having to to do this throughout the code deifes the object of a 'shortcut' such as :), unless i have missed something here it would be alot simpler and quicker to just use the html tag <img> wouldnt it....
|
|
12-24-2005 08:33 PM |
|
|
Pages: (3):
« First
«
1
[ 2 ]
3
»
Last »
|
|
|