For example, I would like to create an array from the elements in this string:
$str = 'red, green, blue ,orange';
I know you can explode and loop through them and trim:
$arr = explode(',', $str);
foreach ($arr as $value) {
$new_arr[] = trim($value);
}
But I feel like there's a one line approach that can handle this. Any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…