Hi can anyone give me an idea on how I can come out with an output like this:
$string = string1-1/string3-3/string3-3/ //this is the original string from DB
//i want to split the strings and put it in the array, and the array should look like this
Array[0] = String
Array[1] = Int
Array[2] = String
Array[3] = Int
...and so on..
For better understanding of my problem, the string from db that I want to split is a set of strings that I concatenate when the user insert it.
Now, I want to split it up into STRINGS and INT so that I can subtract the INT value to the quantity of the STRING.
What I have done so far is like this:
$result1 = mysqli_query($connection, "SELECT orderline.product_id, product_name, category_id, orderline.qty_order, accessoryName
FROM orderline
INNER JOIN products
ON products.product_id = orderline.product_id
WHERE category_id = 10
AND orderline.order_no = $orno ");
while($row1 = mysqli_fetch_assoc($result1)) {
$pcname = $row1['product_name']; //get the product name
$qty_order1 = $row1['qty_order'];
$aName = $row1['accessoryName']; //save accessory name to variable
$ACname = explode("/", $aName); //ouput array[0]: name1-qty1, array[1]: name2-qty2, array[3]: name3-qty3
for ($a = 0; $a < count($ACname); ++$i) { //loop count: array size
//loop split array[0] to array[n]
$ACEname = explode("-", $ACname); //ouput array[0]: name1, array[2]: price1, array[3]: name2, array[4]: price2
In my last line of code, I don't know what to do next.. Anyone have an idea on how I would come up to what I want? Suggestion please. Thanks!