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 !

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
DMCA.com Protection Status
0
Would love your thoughts, please comment.x
()
x