Get the App
SLTechnology News&Howtos  ›  Development  › 

How to separate arrays by commas in php

Shulou Source: shulou.com Published: 2022-06-03 10:51:19 10月01日 Update

This article will explain in detail how php is separated into arrays by commas. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.

Php Comma Separated to Array Method: 1. Create a PHP sample file;2. Define the string to be converted;3. Convert the string to an array by comma separation through the "explode (',', $myString);" method.

Operating environment: Windows 7 system, PHP 7.1 version, Dell G3 computer.

Split my string input into an array at commas

Examples of strings include:

9,admin@example.com,8

The conversion method is as follows:

$myString = "9,admin@example.com,8";$myArray = explode(',', $myString);print_r($myArray);

Output:

Array( [0] => 9 [1] => admin@example.com [2] => 8)

The explode() function breaks up strings into arrays.

Note: The "separator" parameter cannot be an empty string.

Note: This function is binary safe.

syntax

explode(separator,string,limit) on "how to use comma to separate array php" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

Tags: Arrays commas characters strings methods articles functions more comments examples good practical secure binary content parameters files articles environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn Linux MariaDB OPPO Reno