Problem: You want to reverse the word or byte order of a string. scheme: reverse by byte: strrev () function reverse by word: you can break down the entire string into independent characters based on the space characters between words, reverse the order of these words, and re-combine the reversed words. Explode () function array_reverse () function implode function
Question: You want to reverse the character or byte order of a string.
Scheme: Byte reversal: the strrev () function reverses by word: you can first split the entire string into independent words based on the space characters between words, and then reverse the order of these words, finally, the reversed words are combined. Explode () function array_reverse () function implode function
$s='my blog lostphp';echo strrev($s).'';$word=explode(' ',$s);$word=array_reverse($word);$s=implode(' ',$word);echo $s;
Summary: array explode (string $ separator, string $ string [, int $ limit]) This function returns an array composed of strings, each element is a string substring, they are separated by the string separator as the boundary points. If the limit parameter is set, the returned array contains up to limit elements, and the last element contains the rest of the string.
If separator is a null string (""), explode () returns FALSE. If the value of separator cannot be found in string, explode () returns an array containing a single string element.
If the limit parameter is negative, all elements except the last-limit element are returned.
Array array_reverse (array $ array [, bool $ preserve_keys]) accepts array as input and returns a new array in reverse order. if preserve_keys is TRUE, the original key name is retained.