Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
Generating backslash in a string in PHP

I have the following string that the ultimate goal is to use it in like sql. The output should be '%"cardSelected":"120-B-110-C"%' .

But the output of this string is generating with backslashes like this below '%\"cardSelected\":\"120-B-110-C\"%'

$search_term = '"cardSelected":"120-B-110-C"';
$like =  '%'. $search_term .'%';
        
$sql = $wpdb->prepare(
       "SELECT * FROM $wpdb->posts WHERE post_status = %s AND post_content LIKE %s;",
       'publish',
       $like,
);

I tried using str_replace as below, but the slashes were not removed either

$search_term = '"cardSelected":"120-B-110-C"';
$like =  str_replace('\\','','%'. $search_term .'%');
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda