Is it possible to display the data in a table separately? [duplicate]

0

I have a table in my database and it contains a column with the following data:

link.com/1, link.com/2, link.com/3, link.com/4

What I would like to know is if I have the query in PHP and return the value of the column where each value comes only to , on one line and the other on another line like this:

link.com/1

link.com/2

link.com/3

link.com/4

Is there any way I can do it?

    
asked by anonymous 15.02.2018 / 07:10

1 answer

0

You can split the string through the comma, so use the explode function:

<?php

$retorno_bd = "link.com/1, link.com/2, link.com/3, link.com/4";

// converte a string em um array
// utiliza a "," para fazer a divisao
$array = explode( ",", $retorno_bd);


foreach($array as $linha){
    echo "$linha \n";
}

?>

View the code on Ideone

    
15.02.2018 / 13:05