Skip to content

How to Remove ‘N’ Number of Characters From Given String Using PHP

One of my Friend Asked me this small Thing , Here this post is about removing N Number of Characters for Given String Using PHP,

By Using PHP Built in Function Called substr() we can do

substr() : Return Part of A String

Example :
$result = substr($str, 0, -n); // 0 is where you want to start, -n means you want to go backward

$result = substr(‘abcdef’, 0, -3); // $result is ‘abc’

If Like my post Like or Share it Explore it

Thanks !

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments