How to set implode in php without separator

WBOY
Release: 2023-03-15 18:28:01
Original
2164 people have browsed it

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)
Copy after login

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);
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!