Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

reverse a string

$
0
0

I have a sting, containing numbers and letters,

 such that:

 

abc  12,345 def

 

I want reversing only the words, so the result will look:

def 12,345 abc.

 

 

I know how to reverse the all string:

$array = explode("    ", $string);
foreach ($array as &$word) { 
   $word = strrev($word);
}
$rev_string = implode(" ", $array);

 

 

but don't know how to deal with the numbers.

 

Thanks
 


Viewing all articles
Browse latest Browse all 13200

Trending Articles