// I would like to search and delete certain words of a session variable. // In this case the variable contains a query that is generated in another PHP file.
// For this I want to eliminate the empty AND.
// The query is the following: $_SESSION["consulta_temporal"] = "SELECT * FROM usuarios WHERE (id='user1') AND () AND (nombre='usuario1'";
<?php
session_start();
$consulta = $_SESSION["consulta_temporal"]; // aqui mando a traer la variable de sesion de otr
if (strpos($consulta, '() AND') !== false) {
$resultado1 = substr($consulta, 6);
}
else{
$resultado1 = $consulta ;
}
echo $resultado1;
?>