Problem:- How to Reverse Word in a String Using PHP?
Contents
hide
Solution
There are to Method to reverse a string
Method 1
To reverse every Word
<?php $string = "Hindi Alerts"; $words = explode(' ', $string); $words = array_reverse($words); $string = implode(' ', $words); echo $string; ?>
Method 2
To reverse every character
<?php $string = "Hindi Alerts"; $rev_string = strrev($string); echo $rev_string; ?>
Leave a Reply