PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
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');
Copy Clear
Copy Format Clear
<?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]]);
Show:  
Copy Clear