我有system("last")
生成的以下字符串。
user1 ftpd11967 89-23-224-162.d Fri Aug 3 01:42 still logged in
如何使用str_replace
替换...
still logged in
...与
<span style='color:green'>still logged in</span>
尝试
system("last", $rawOutput);
$output = str_replace ( "still logged in" , "<span style='color:green'>still logged in</span>" ,$rawOutput );
echo $output;
除了系统之外,我也尝试过:
$rawOutput = shell_exec("last");
$output = str_replace( "still logged in" , "<span style='color:green'>still logged in</span>" ,$rawOutput );
echo $output;
答案 0 :(得分:2)
试试这个
// "user1 ftpd11967 89-23-224-162.d Fri Aug 3 01:42 still logged in"
system("last", $rawOutput);
$output = str_replace ( "still logged in" , "<span style='color:green'>still logged in</span>" ,$rawOutput );
echo $output;