I am working on a code in which I fetch a particular row from a mySQL database using php. The value that I take from the row is like "CSS, HTML, JAVASCRIPT, AJAX, BOTSTRAP,DJANGO, LAYNX,BOTSTRAP,JQUERY,AJAX"
this is a single sentence/value from a row. what I want is to convert this sentence into an array and remove duplicate values and use that array further. My code goes as below.
<?php $sql = "SELECT * FROM user_info WHERE user_id = '$user_id' ";
$run_query = mysqli_query($con,$sql);
$row = mysqli_fetch_array($run_query);
$string = $row["skills_covered"];
$string = array_unique(explode(",", $string));
$count=count($string);
for($ib=0;$ib<$count;$ib++){
echo "<li><a href='#' > $count |$string[$ib] </a></li>";
}
?>
the output that I'm getting is
10 |CSS
10 | HTML
10 | JAVASCRIPT
10 | AJAX
10 | BOTSTRAP
10 |DJANGO
10 | LAYNX
10 |BOTSTRAP
10 |JQUERY
10 |AJAX
the output that I want is
8|CSS
8| HTML
8| JAVASCRIPT
8| AJAX
8| BOTSTRAP
8|DJANGO
8| LAYNX
8|JQUERY
Thanks in advance