-3

我有以下字符串由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;
4

1 回答 1

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;
于 2012-08-03T00:33:43.893 回答