How to explode PHP string by new line?

Spread the love

Sometimes, we want to explode PHP string by new line.

In this article, we’ll look at how to explode PHP string by new line.

How to explode PHP string by new line?

To explode PHP string by new line, we call explode with PHP_EOL.

For instance, we write

$skuList = explode(PHP_EOL, $_POST['skuList']);

to call explode with PHP_EOL and $_POST['skuList'] to explode the $_POST['skuList'] string by any new line character into the $skuList array.

Conclusion

To explode PHP string by new line, we call explode with PHP_EOL.

Leave a Reply

Your email address will not be published. Required fields are marked *