0

これは私のコードです:

$css = ".block{float:right; text-align:right;padding:0 20px 0 0; margin:0 0 0 0;}.block h2{font-size:24px; color:#2b7538; font-weight:normal; text-align:right; padding:10px; margin:10px 0 0 0; text-align:left}.block  p{line-height:30px;margin-top:20px; float:left}";

$search = array("float:left","text-align:left","float:right","text-align:right");
$replace = array("float:right","text-align:right","float:left","text-align:left");

echo str_replace($search, $replace, $css);

左から右と右から左を同時に交換するにはどうすればよいですか?

4

2 に答える 2

0
$search  = array('right', 'left', 'xxx');
$replace = array('xxx', 'right', 'left');
$subject = 'right then left then right';
$return = str_replace($search, $replace, $subject);

戻り値 :

$ subject:右、左、右

$ return:左、右、左

于 2012-05-14T12:37:18.360 に答える