Read array from a field

0

In a sql query, it returns me that $ 10.30,40.50 value from the "mark_ups_range" fields

How to read and quit lines in these values? example

10

30

40

50

$sql1 = "SELECT mark_ups_range FROM config_politicas WHERE id_transfer = '1' ";
$resultado1 = mysql_query($sql1) or die( mysql_error());
while ($linha = mysql_fetch_assoc($resultado1)) {

$id2=$linha['mark_ups_range'];// 10,30,40,50

}
$arr = explode(', ', $id2);
foreach ($arr as $v) {
echo '<br>';
echo $arr;
}
    
asked by anonymous 04.02.2018 / 19:20

1 answer

1

In your explode you have one more space. Another problem is that with each redo of foreach you are printing the value of $arr when you should actually print the value of $v . Do as follows:

$arr = explode(',', $id2);
foreach ($arr as $v) {
    echo '<br>';
    echo $v;
}

The as of foreach will cause each repetition to get an item of array and stored in the variable on the right, which in this case is $v .

    
04.02.2018 / 19:41