ray-solomon
asked on
Cleaning textarea contents
I created this to remove duplicates and trim each line of a textarea box. And it works.
I am wondering if there is a more efficient way to write this and possibley make it into a function.
// TRIM, CREATE ARRAY, REMOVE DUPLICATES, MAKE STRING, TRIM AGAIN
$array = array_unique(explode("\r\n ", trim($field1)));
$cleaned = implode("\r\n", $array);
$trimmed = preg_replace ( "/\s\s+/" , "\r\n" , $cleaned );
echo $trimmed;
I am wondering if there is a more efficient way to write this and possibley make it into a function.
// TRIM, CREATE ARRAY, REMOVE DUPLICATES, MAKE STRING, TRIM AGAIN
$array = array_unique(explode("\r\n
$cleaned = implode("\r\n", $array);
$trimmed = preg_replace ( "/\s\s+/" , "\r\n" , $cleaned );
echo $trimmed;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER