$dis=$mysqli->query("select * from article"); while ($diss = $dis->fetch_assoc()) { $t=$diss['title']; $abbreviation = explode(' ', trim($t ))[0]; echo $abbreviation; echo'</br>'; // will print Hello }