I have a value from mysql which I want to split into multiple input fields in a form.
// This is the value from mysql...
$value = "10 - Coles, 15 - Aldi, 5 - Target, 7.77 - Kmart";
// This is how I want to split it....
$amt_1 = "10";
$desc_1 = "Coles";
$amt_2 = "15";
$desc_2 = "Aldi";
$amt_3 = "5";
$desc_3 = "Target";
$amt_4 = "7.77";
$desc_4 = "Kmart";
//So that it can be displayed in input boxes...
<input type="text" value="<?php echo $amt_1; ?>" />
<input type="text" value="<?php echo $desc_1; ?>" />
<input type="text" value="<?php echo $amt_2; ?>" />
<input type="text" value="<?php echo $desc_2; ?>" />
<input type="text" value="<?php echo $amt_3; ?>" />
<input type="text" value="<?php echo $desc_3; ?>" />
<input type="text" value="<?php echo $amt_4; ?>" />
<input type="text" value="<?php echo $desc_4; ?>" />
Now, there is a condition.
The $value can be empty or it may not enough to be able to split into 4 parts, means it can be $value = "10 - Coles, 15 - Aldi"; to be able to fit into $amt_1, $desc_1 and $amt_2, $desc_2. or any set of 1, 2, 3 or 4 splits.
$valueis empty