Reversing the order of the columns word string php

function strturn($str){
     $pstr='';
        $sstr='';
        for($i=0;$i<strlen($str);$i++){
            if($str[$i]==' '){
                $pstr=$pstr.$sstr.' ';
                $sstr='';
            }else{
                $sstr=$str[$i].$sstr;
            }
        }
        $pstr=$pstr.$sstr;
        return $pstr;
    }
$str='student. a am I';
$res=strturn($str);
$parm=strrev($res);
print_r($parm);

 

Guess you like

Origin www.cnblogs.com/gwhm/p/11204861.html