How to String Replace Backslash in PHP?
Nov 25, 2022
Hi Dev,
This tutorial will give you example of how to string replace backslash in PHP. We will use string replace backslash PHP \\ \ with code examples. you can understand a concept of using PHP replace backslash. step by step explain PHP stripslashes() function.
The stripslashes() function removes backslashes added by the addslashes() function. To add backslash inside array of strings, use json_encode().
Example: 1
index.php
<?php
echo stripslashes("Who\'s john and peter?");
?>
Output:
Who's john and peter?
Example: 2
index.php
<?php
$value = [
"ADD", "REMOVE","SELECT","MODIFY"
];
echo json_encode(json_encode($value)) . "
";
?>
Output:
"[\"ADD\",\"REMOVE\",\"SELECT\",\"MODIFY\"]"
I hope it could help you...
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example