Really smiple but not easy - backspace in php

Hi every body,
haaaaaaaaaaa … really it’s funny :rofl:

I spend about 30min looking for backspace (back delete) in php codes… :blush:

how can i make it… in other languages we use \b how can i make it in php??

(: :eye:

$bs = chr(8);

it not working, i write this code


<?
$bs = chr(8);
echo '--'.$bs;
?>

output
– and specail chr…

poor RUBA…
can’t make backspace in php, I can’t delete \ from string :frowning:

chr(8) should produce the backspace character, but i dont think that is what you really want.

take a look at substr() instead


$string = 'abc';
echo substr($string, 0, -1); // 'ab'

you may also want to look at trim()

thanks clamcrusher for your care,

let us say I have this string …

$str =“\ \ test1\ test2\ test3”;

I want to remove \ from the begining,
I must use backspace, I can’t use substr , or str_replace all what i want to use backspace (\b)

in other language i’ll write
$str =“\ \ test1\ test2\ test3”;
echo “\b”.$str ;
it will display
test1 test2 test3

when I try to write it in php the output will be like this
test1 test2 test3

there is two tab

$str ="\	\	 test1\	 test2\	 test3";
echo str_replace("\	","",$str);

thanks foofoonet,
but i can’t use str_replace …

there is no backsapce in php???
:injured:

there is no backsapce in php

It’s not a PHP thing really. chr(8) works fine in PHP console applications but a backspace isn’t like \
\r etc as a backspace doesn’t have a representation, it just deletes, and a browser struggles to render an entity that can’t be expressed as text.

thanks u markl999 :inspector: ,
:headbang:
I understand now
:vinnie:

Why can you not use substr?

$strNewText = substr($strOldText, 0, 2)