Implode and explode in PHP with example -

Illustration of Implode and Explode in PHP

  • “separator” separates the resultant string.
  • and “array” is the input array that is taken as the multiple inputs.
<?php $cars = array('Maruti','Volvo','BMW','Marcedes'); echo implode(' , ', $cars).'<br>'; echo implode(' + ', $cars).'<br>'; echo implode(' and ', $cars).'<br>'; echo implode(' or ', $cars); ?>
Maruti , Volvo , BMW , Marcedes
Maruti + Volvo + BMW + Marcedes
Maruti and Volvo and BMW and Marcedes
Maruti or Volvo or BMW or Marcedes
  • ‘separator” separates the string elements
  • “array” is the input string
<?php $cars = array('Maruti','Volvo','BMW','Marcedes'); for($i=0;$i<sizeof($cars);$i++) { echo 'The name of the car is '.$cars[$i].'<br>'; } ?>
The name of the car is Maruti
The name of the car is Volvo
The name of the car is BMW
The name of the car is Marcedes

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bipsmedium

Bipsmedium

Hi, This is Biplab and I am web developer well versed in PHP and other open source technologies. I am here to share my experience with the community.