Php Flow » Php

PHP: preg_replace Php function

This function is used for find and replace on string or an array.We can apply this function on full list of array and replace with specific staring or array of string.This function contain for parameter find,replace,source Data and count.In this function by default limit is -1(means no limit) and count is optional.
Syntax:

  1. preg_replace(find,replace,$data,$limit,$count);  

Example:

  1. $data=” We can give it one thing to find and replace”;  
  2. //create arrays   
  3.  $find = array (‘/ replace /’‘/ find /’);   
  4.  $replace = array (‘Replace’, ‘Find’);   
  5.    
  6.  // replace with array values   
  7.  echo preg_replace ($find$replace$data);   
  8.    

Did you enjoy this article? Share it!

About the Author:

Hi, This is Parvez Alam from India. I am software developer with 4 years’ experience in web development. I have submitted articles on PHP, Mysql, Magento,CSS, HTML, jQuery, web designing and social API. You can subscribe to my blog via RSS/Twitter/Google plus and Facebook. parvez1487(at)gmail(dot)com

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>