我有这样的场景:
$data = "A,B,C=>fruit'\n'D,E,F=>veggie'\n'A,D=>mix"
$rules = array_map('trim', explode('\n', $data));
$i = 1;
foreach ($rules as $rule) {
$letter_group."_".$i = array_map('trim', explode('=>', $rule));
$letter.$i = array_map('trim', explode(',', $letter_group."_".$i[0]));
$group.$i = array_map('trim', explode(',', $letter_group."_".$i[1]));
$i++;
var_dump($letter.$i);
var_dump($group.$i);
}
但这不起作用。如何获得这些输出?
$letter1 = array('A','B','C');
$letter2 = array('D','E','F');
$letter3 = array('A','D');
$group1 = array('fruit');
$group2 = array('veggie');
$group3 = array('mix');