這是一個非常新手的問題,但我就是想不通問題出在哪裏 所以請原諒......更換用下劃線空間用PHP
這裏就是我想實現 - >$new = 'OMG_This_Is_A_One_Stupid_Error';
這裏是我從該代碼得到 - >$new = 'OMG This Is A One Stupid_Error';
<?php
$find = 'OMG This Is A One Stupid Error'; //just an example
$offset = 0;
$search = ' ';
$length = strlen($search);
$replace = '_';
while($substring = strpos($find, $search,$offset))
{
$new = substr_replace($find, $replace,$substring,$length);
$offset = $substring + $search_length;
}
echo $new;
?>
你可能想查找http://php.net/manual/en/function.str-replace .php – andrewsi
http://php.net/str-replace或者換句話說:你不僅重新發明了輪子,而且還用火和石頭殺死了動物的食物;) – KingCrunch
@KingCrunch :)) –