PHP : Removes slashes contained in a string

In this tutorial learn how to Removes slashes contained in a string using function with stripslashes() method.




Tutorial

<?php
    /**
  * Strip Slashes
  *
  * Removes slashes contained in a string
  *
  * @param mixed string
  * @return mixed string
  */
 function strip_slashes($str)
 {
  if ( ! is_array($str))
  {
   return stripslashes($str);
  }

  foreach ($str as $key => $val)
  {
   $str[$key] = strip_slashes($val);
  }

  return $str;
 }
 echo strip_slashes("f\\'oo b\\'ar");
?>
Above Tutorial Output:

f'oo b'ar

No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...