简体   繁体   中英

echo backspace inside string

Pretty simple but I'm looking for the easiest way (HEX?) and it's not working...

I want to add to the string backspaces (delete last character)...

Here is my simple code :

<?php

    echo '<br>Delete me!!!'."\x8"."\x8"."\x8"."\x8"."\x8"."\x8"."\x8"."\x8"."\x8"."\x8"."\x8"."\x8";

?>

Small tweak needed here ;)

backspace is a special character that is interpreted by editors and various text input boxes as a request to remove the character before the cursor. The backspace character itself has no magical powers, it cannot make disappear something that was already displayed.

If you need to remove some characters from a string in PHP you can use substring() , str_replace() , preg_replace() or other string handling function.

For example, you can ignore the last 3 characters from a string like this:

echo(substr('blah-blah', 0, -3));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM