Explain the types of functions for Splitting String?



Explain the types of functions for Splitting String?..

Answer / Indal Babu

In PHP, there are several functions to split a string. Here are a few examples:
1. str_split() - Splits a string into an array.n Example: `$string = "Hello World"; $array = str_split($string); print_r($array);`
2. explode() - Splits a string into an array by a specified delimiter.n Example: `$string = "Hello, World"; $array = explode(",", $string); print_r($array);`
3. preg_split() - Splits a string using a regular expression pattern as the delimiter.n Example: `$string = "Hello( World)"; $pattern = /( .)/; $array = preg_split($pattern, $string); print_r($array);`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

Where is session value stored?

1 Answers  


How can we encrypt the username and password using PHP?

3 Answers   Rushmore Consultancy,


What is difference between ksort() and usort() functions.

1 Answers  


What is polymorphism php?

1 Answers  


What are the four scalar types of php?

1 Answers  


Is strcmp case sensitive?

1 Answers  


What is json php?

1 Answers  


How to assigning a new character in a string using php?

1 Answers  


what is the maximum size of databasi in mysql?

4 Answers  


please can any one tell is there any openings for freshers in PHP ...please tell the company name and address sir where can i find ..php related companies and how much i expect salary as a fresher in php ..i finished my LAMP course i done my mca ..i seen in many job portals there is no job for freshers in php can any one tel me please in chennai i need php jobs ..? thank u friends

1 Answers  


What is the current stable version of php? What advance thing in php7?

0 Answers  


What is the purpose of constant() function?

1 Answers  


Categories