<Original message>
From: Gerard Samuel <[EMAIL PROTECTED]>
Date: Thu, Sep 06, 2001 at 01:10:15AM -0400
Message-ID: <[EMAIL PROTECTED]>
Subject: [PHP] str_replace and arrays

> Hey all.  Im trying to reduce some lines of code that has muliple lines 
> of str_replace.  I figure lets try using arrays but its not working.
> E.g. I have about 15-20 lines like this.
> $message = str_replace(":D", "<IMG 
> SRC=\"images/forum/icons/icon_biggrin.gif\">", $message);
> 
> Im trying
> $path = "images/forum/icons/";
> $one = array(":D",":)");
> $two = array("$path"."icon_biggrin.gif", "$path"."icon_smile.gif");
> message = str_replace($one, $two, $message);
> 
> do you see anything wrong....

</Original message>

<Reply>

Well... you forgot the $ sign for message at the last line, it
should be $message= io message=
Because the rest of the construction should just work. Check out my
simple example below. You haven't said what goes wrong exactly, btw.

--- PHP example ---
<?php

$txt = "And now :D some :-) smiley =( kind of ;) thing.";
$match = array (":D", ":-)", "=(", ";)");
$replace = array ("1", "2", "3", "4");

print str_replace($match, $replace, $txt);

?>
--- End of PHP example ---

</Reply>

-- 

* R&zE:


-- 
-- Renze Munnik
-- DataLink BV
--
-- E: [EMAIL PROTECTED]
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
--
-- Stationsplein 82
-- 2011 LM  HAARLEM
-- Netherlands
--
-- http://www.datalink.nl
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to