I want to evaluate the url and, depending on what it contains, do different actions (all the urls written are redirected to the index )
but I have come to a problem with variables, that is to say
a normal url would be for example
http://localhost/myapp/productos
and one with Variable could be
http://localhost/myapp/productos/find/2
Sent the url to then reply with a json
The code I have so far
$var = $_GET['url'];
switch ($var) {
case "productos":
echo "i es igual a 0";
break;
//Aqui esta el problema no se como decirle a php que omita el numero que escriba el usuario
case "productos/find/":
echo "i es igual a 1";
break;
case 2:
echo "i es igual a 2";
break;
}
You can declare the following:
In short, what I did was separate your url into parts and eliminate the last element and assign to the variable compare url if you do not pass a number at the end of the url and if not I assign the variable sin_id which is the url formatted without the number.
Well finally I solved the problem with this code
What it does is that it extracts any 10-digit number from a string and then when comparing I only add the variable in which the number that I extracted is