Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
CREATE TABLE tableee (
`id` INTEGER,
`tag` VARCHAR(21)
);
INSERT INTO tableee
(`id`, `tag`)
VALUES
('1', 'wordpress, psd , html'),
('2', 'wordpress, html'),
('3', 'wordpress'),
('4', 'psd');
<?php
$query = mysqli_query($mysqli, "SELECT tag FROM tableee ");
$array2=array();
while($row=mysqli_fetch_assoc($query))
{
$array = explode("," ,$row['tag']);
for($i = 0; $i<count($array); $i++)
{
array_push($array2, trim ($array[$i]) );
}
}
$array3 = array_count_values($array2);
$array4 = array_keys($array3);
print_r( $array4[0] ) ;
print_r( $array3[ $array4[0]]);