PHP explode() – How to break a string into parts in PHP

Default Image
  1. Home
  2. PHP
  3. PHP explode() – How to break a string into parts in PHP

PHP explode() function breaks a string into parts. You can specify any character (which should be present in the string) to break it up into two or more segments. The function accepts two main parameters:

$contact = "fname|lname|address|phone|email";
$details = explode("|", $contact);

The string is stored in $contact variable. We use the pipe “|” character as a separator that will be used to split the string into segments.

PHP Programming