How to use explode() Function In PHP
The explode() function is useful when dealing with delimited strings. It splits a string into an array based on a specified delimiter and assigns the values to variables.
PHP
<?php $str = "Geeks, Noida, +91-9876543210" ; list( $name , $address , $mobile ) = explode ( ',' , $str ); echo "$name, $address, $mobile" ; ?> |
Geeks, Noida, +91-9876543210
How to Assign Multiple Variables in One Line in PHP ?
In PHP, assigning multiple variables in one line can be a handy and efficient way to streamline your code. This technique not only makes your code more concise but also improves readability. There are several approaches to achieve this, each with its own syntax and use cases.
Table of Content
- Using Multiple Assignment
- Using list() Function
- Using explode() Function
- Using Short Array Syntax