Horje
How to get first 3 words from a sentence by PHP | PHP String Code
How to get first 3 words from a sentence by PHP

The tag is: array_slice


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



Read Full::
PHP String Code
Category:
PHP Tutorial Code
Sub Category:
PHP String Code
Uploaded:
1 month ago
Uploaded by:
Admin
Views:
13

Related Articles
How to extract words from Sentence in PHP PHP String Code
How to check if string is_numeric() Function in PHP PHP String Code
How to get only text from HTML Source Code by PHP PHP String Code
How to get first 3 words from a sentence by PHP PHP String Code
How to work if empty value does not else PHP String Code

Single Articles
How to extract first 3 words from a sentence by PHP

Share on: