How to remove N characters at the end of a string in PHP

1 Answer

0 votes
$s = "php programming";
  
$N = -3;

$s = substr($s, 0, $N);
 
var_dump($s);



/*
run:
          
string(12) "php programm" 
   
*/

 



answered Oct 12, 2019 by avibootz

Related questions

2 answers 195 views
2 answers 160 views
1 answer 196 views
2 answers 207 views
1 answer 221 views
2 answers 118 views
...