php mysqli data can't properly echo after fetc

2019-09-19 13:58发布

问题:

In my database I have few data with comma . At first please watch my DATABASE TABLE .

and now I want to fetch and echo data IN A SINGLE LINE on the bill . Please watch the bill UI Example:- pizza abc 230 70 40 7000 1 6930 will echo on 1st line and then also cake pnd 144 842 80 400 3 385 will echo in 2nd line

and this process will do complete using loop to make table rows increment ad decrement dynamically .]

回答1:

The explode() function breaks a string into an array.

Note: The "separator" parameter cannot be an empty string.

Example :

<?php

    $product_type = explode(',',"pizza,cake,biscuit,noodles");
    $product_name = explode(',',"abc,pnd,bun,dgj");
    $produ_cartoo_quantity=explode(',',"230,144,878,906");
    $produ_cartoo_weight=explode(',',"70,842,612,794");

    for($i=0;$i<count($product_type);$i++)
    {
        echo $product_type[$i]." ";
        echo $product_name[$i]." ";
        echo $produ_cartoo_quantity[$i]." ";
        echo $produ_cartoo_weight[$i]."<br>";

    }

?>

Output :

pizza abc 230 70
cake pnd 144 842
biscuit bun 878 612
noodles dgj 906 794