Home  >  Article  >  Backend Development  >  How to set implode in php without separator

How to set implode in php without separator

WBOY
WBOYOriginal
2022-04-18 17:39:301962browse

In PHP, you can use the first parameter of the implode() function to set no delimiter. The first parameter of the function is used to specify the content placed between the array elements. The default is an empty string. , you can also set the first parameter to empty, the syntax is "implode (array)" or "implode ("", array)".

How to set implode in php without separator

The operating environment of this article: Windows 10 system, PHP version 8.1, Dell G3 computer.

How to set implode without delimiter in php

implode() function returns a string composed of array elements.

The syntax is:

implode(separator,array)

The parameters are expressed as follows:

  • separator is optional. Specifies what is placed between array elements. Default is "" (empty string).

  • array required. Arrays to be combined into strings.

Set the parameter separator to empty or to an empty string to return results without separators.

The example is as follows:

<?php
$arr = array(&#39;1&#39;,&#39;2&#39;,&#39;3&#39;,&#39;4&#39;);
echo implode($arr)."<br>";
echo implode("",$arr)."<br>";
echo implode("-",$arr);
?>

Output result:

How to set implode in php without separator

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to set implode in php without separator. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn