Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    php
  » Find/Replace
      by thebra
 Page 1 of 1 
   

(Login to remove green text ads)
Here is how easy it is to replace characters in a string.

PHP Code:
<?PHP

$the_string 
'I love beans!';

//replace beans with cheese
$the_string str_replace("beans","cheese",$the_string);
echo 
$the_string;

?>

This will output:

I love cheese!
----------------------------

String replace works like this:
str_replace(word_2_replace,replace_with_word,strin g_2_search)

This can be usefull for many different things. Such as you can remove unwanted words (dirty words!) from a message board.




 
 Page 1 of 1 
   

Rate This Article
1 2 3 4 5 6 7 8 9 10





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle