Jump to content

str_replace - problem with img


web_master

Recommended Posts

Hi,

 

I got 2 "str_replace"-es in script.

 

One is for a smilies and looks like: $s = str_replace(": )","<img src=\"media/icons/smilie_01.gif\">", $s);

 

The other is: $s = str_replace(".",". ", $s);

 

Well, when I add the latest str_replace (dot change to dot+space) the images is dissapears... :(

 

In source code the image src looks like this: <img src="media/icons/smilie_01.%20gif">

 

What can I do, to str_replace don't chande the dot to dot+space in img - "smilie_01.gif -> smilie_01.%20gif"?

 

Thanx in advanced!!!

Link to comment
Share on other sites

you will be breaking the url as whitespace in a url is not allowed. as all characters need to be present the " " (space) is substiuted by %20

 

Give me the RAW data presumably $s before you manipulate it and give me what you WANT the output to be.  And as the last poster said....if you DO need a space, please advise WHY

 

Will

Link to comment
Share on other sites

well...

 

This changes is for a better look of shout-box.

 

The shout boxes width is given. But lots of a visitors when read texts forgot to insert the space after the dot (and comma). This result somethimes the very wide "word". And this result that a shout-box need a scrollink when You want to read this text.

 

As You see this will be a "cosmetic" only.

Link to comment
Share on other sites

<?php
$query_shout_return = mysql_query ("SELECT * FROM `shout_box` WHERE shout_mutat = '1' ORDER BY `shout_id` DESC LIMIT 0, 30");

	if(!$query_shout_return) {
		print mysql_error();
		exit;
	}

while($request_shout_return = mysql_fetch_array($query_shout_return)) {

	$s = nl2br($request_shout_return['shout_txt']);
	$s = str_replace(": )","<img src=\"media/icons/smilie_01.gif\">", $s);
	$s = str_replace(":-)","<img src=\"media/icons/smilie_01.gif\">", $s);
	$s = str_replace(": (","<img src=\"media/icons/smilie_02.gif\">", $s);
	$s = str_replace(":-(","<img src=\"media/icons/smilie_02.gif\">", $s);
	$s = str_replace(": D","<img src=\"media/icons/smilie_03.gif\">", $s);
	$s = str_replace(",",", ", $s);
?>

 

$s is a shout-boxes text

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.