How to replace a content that contains backslash and fowardslashes in php

Website Design |

6th Jun, 2023

Click here to share

The code below replaces part of the content that contains multiple forward and backslashes in php


function dazito_filter_content($content)


    $content = "\/en\/wp-json\/geodir\/v2\/";

    $rep = "dzbsh";

    $content = str_replace('\\', $rep, $content);


    $content = preg_replace("/(en$rep|es$rep|de$rep)\/wp-json$rep\/geodir$rep/", 'wp-json\/geodir', $content);


    $content = str_replace($rep, '\\', $content);


    return $content;


Leave a Reply


Total of 0 Comment