I have a textarea where users can put variables like this :
VARIABLE=foo
RANDOM=iloveit
GREAT=amazing
I need to transform this in an array of parameters.
So i did this function (who works) :
public static function cleanWebhookTextarea($textareaLines){
$textareaLines = preg_split('/(;|,|\r\n,|\r,|\n)/', $textareaLines);
$params = array();
foreach ($textareaLines as $line){
$line = preg_split('/(=)/', $line);
$params[$line[0]] = $line[1];
}
return $params;
}
This return me what i want, so :
array:3 [▼
"VARIABLE" => "foo"
"RANDOM" => "iloveit"
"GREAT" => "amazin"
]
But i wondering if there is a quickest way to do what i want ?
Thanks
=to mark key-value pairs. Alternatively you could create paired input fields for keys and their values.\r\nof=+error=trapping\tin=there