How to limit string length after a certain character in PHP

  • Tech Area
  • August 2, 2023


In this tutorial, We will learn how to limit string length after a certain character in PHP. We are using substr() and strpos() functions to limit string length after first “.”.

Solution

<?php 
echo substr("Tech Area Tutorials is the Programming & Web Development blog. Our aim is to provide best solution on programming and web development for web professionals like developers, programmers and freelancers.",0,strpos("Tech Area Tutorials is the Programming & Web Development blog. Our aim is to provide best solution on programming and web development for web professionals like developers, programmers and freelancers.",'.')+1); 
?>

Output

Tech Area Tutorials is the Programming & Web Development blog.


Subscribe us via Email

Join 10,000+ subscriber

Subscribe on YouTube