Horje

How to extract first 3 words from a sentence by PHP

Follow the Example.
index.php
Example: PHP
<?php
$first3word = 'WWE is the best sports'; 
$first3word = implode(' ', array_slice(explode(' ', $first3word), 0, 3));
echo $first3word;
?>

Output should be:

How to extract first 3 words from a sentence by PHP




Type:
php
Category:
Web Tutorial
Sub Category:
PHP String Tutorial
Uploaded by:
Admin