Saturday, 26 July 2014

Filled Under:

explode() function in php

Explode() Function():

                            explode() function is use to break the string into array. For example we have a string “hello I am using programminglogic” we can break the string from space it mean “hello” is in zero index of array “I” is in first index and so on

Syntax:

             explode(separate , string, limitation)

separate: give the separator where u want to break the string it may b space or comma etc

limitation: give the maximum limit of string element where you want to break the string it should be greater then zero.(optional)

Example:

<?php

$str= “hello I am using programminglogic”;

Print_r(explode(' ',$str,0)); //I use separator space

Print_r(explode(' ',$str,2));

Print_r(explode(' ',$str));     //if I don’t use the limitation the whole string will be break.

?>

Output:

          Array ( [0] => hello I am using programminglogic  ) 

          Array ( [0] => hello  [1] => I am using programminglogic  )

          Array ( [0] => hello  [1] => I [2] => am [3] => using [4] => programminglogic  )




0 comments:

Post a Comment