开发者

How add to a backspace character to a string literal?

I use \b to generate backspace in PHP: But I think it doesn't work:

        if(isset($_GET['submit'])){
            $n = $_GET['n'];
            $c = $_GET['c'];
            $space = " "; $i=0; $j=0; $k=0;

            do{
                $space = $space." ";
                $i++;
            }while($i 开发者_StackOverflow社区< $n);

            for($j=0; $j < $n ; $j++){
                echo $space;

                for($k=0; $k < $j*2 - 1; $k++){
                    echo $c;
                }
                echo $space."\b";
                echo "<br />";
            }
        }


If you want to delete last char in a string just do:

$space = substr($space,0,-1);     //> Reccomanded

or

substr($space,0,count($space)-1); //> Slower

or

substr_replace($space,'',-1);     //> Uglier


Maybe you mean this: "\x8" ?


Indeed, it's not on the list. You have to use the octal or hexadecimal notation.

In any case, the backspace character has little use outside a text console, not to mention HTML.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜