ItSolutionStuff.com

PHP Explode Every Character into Array Example

By Hardik Savani May 14, 2024
PHP

Hi,

This post will give you example of php explode every character into array. In this article, we will implement a php explode all characters. you will learn explode all characters php. you can see how to explode all character in php using str_split().

Few days ago i was working on my laravel app and i need to explode all characters into array, i know php has explode function but it not works with this requirement. so i research and found str_split() function where it gives you explode all characters into array.

So, let's see bellow very simple example here:

Example:

<?php

$name = "Hardik Savani";

$arr = str_split($name);

print_r($arr);

?>

Output:

Array

(

[0] => H

[1] => a

[2] => r

[3] => d

[4] => i

[5] => k

[6] =>

[7] => S

[8] => a

[9] => v

[10] => a

[11] => n

[12] => i

)

i hope it can help you...

Tags: PHP
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube