subtrair string php

//if you know what stirng you want to subtact then use
// str_replace($search, $replace, $subject)
$x =  "Hi, I am uzair and I am a php dev.";
echo str_replace("and I am a php dev.", "",$x);

/**
or
if you don't know and what to subtract just last two characters or 
5 ch at the begning etc then use substr()
**/ 
  
$rest = substr("abcdef", -1);    // returns "f"
$rest = substr("abcdef", -2);    // returns "ef"
$rest = substr("abcdef", -3, 1); // returns "d"

  
uzii