Skip to content

Instantly share code, notes, and snippets.

@adicahyaludin
Created March 30, 2023 08:40
Show Gist options
  • Save adicahyaludin/eb2c88f00a7669ccadb5a39434a12e83 to your computer and use it in GitHub Desktop.
Save adicahyaludin/eb2c88f00a7669ccadb5a39434a12e83 to your computer and use it in GitHub Desktop.
textarea to array in php
<?php
$textarea_string = 'lorem
ipsum
dolor
sit
amet';
$textarea_arr = preg_split('/[\r\n]+/', $textarea_string, -1, PREG_SPLIT_NO_EMPTY);
echo '<pre>'.print_r($textarea_arr,1).'</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment