I am new in PHP. I have a code in which i use foreach loop to display data in table of explode function.
Here i have a question
The data in my db is
Here you see After Aatir there is a blank space. When i use loop to print data
<?php
ini_set('error_reporting', E_ALL);
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "pacra1";
$conn = new mysqli($servername, $username, $password, $dbname);
$sql = "SELECT * FROM `pacra_clients` WHERE `id` = 50";
$conn->multi_query($sql);
$result = $conn->use_result();
echo $conn->error;
$row = $result->fetch_assoc();
$liaison_one = $row['liaison_one'];
$liaison_one_chunks = explode(",", $liaison_one);
echo '<table border="01">';
foreach($liaison_one_chunks as $row){
echo '<tr>';
$row = explode(',',$row);
foreach($row as $cell){
echo '<td>';
echo $cell;
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
?>
The result of my code is
In result you can see that there is a blank cell due to blank space in data.
Is it possible that i can skip blank space which is in my data???


$row = $result->fetch_assoc($sql);if()condition that when the string isempty(), don't create a rowforeach($row as $cell) { if(!empty($cell)) { echo "<td>{$cell}</td>"; }}ImplodeandExplode