My Stuff
Username

Password

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


Find/Replace


Your rating: None Average: 3 (1 vote)

Here is how easy it is to replace characters in a string.

<?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,string_2_search);

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You can use BBCode tags in the text.
  • You can enable syntax highlighting of source code with the following tags: [code], [blockcode], [asp], [awk], [c], [cpp], [csharp], [drupal5], [drupal6], [java], [javascript], [jquery], [mysql], [perl], [perl6], [php], [python], [ruby], [sql], [vb], [vbnet], [xml].
  • Use to create page breaks.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.