Concatenate Array elements for Human Reading - Php

Concatenate Array el

Snippet Code


  
Rate this page :
  [ 0 votes]

This Source code used to Concatenate the Array Elements.For Example: Array is to be Printed.. John,Mary and Ishmal

<?php $array = array('John', 'Mary', 'Ishmal'); echo concatenate($array); function concatenate($elements, $delimiter = ', ', $finalDelimiter = ' and ') { $lastElement = array_pop($elements); return join($delimiter, $elements) . $finalDelimiter . $lastElement; } ?>

Tags


Ask Questions

Ask Question