4
When I create the code:
$urlAtual = "https://www.meusite.com.br/customer/account/create/";
$parteurl = explode('/', $urlAtual);
for($i=0;$i<=6;$i++){
$parteurldesejada = $parteurl[$i] . "<br>";
echo $parteurldesejada;
}
It prints in the browser this:
https:
www.meusite.com.br
customer
account
create
See that the value [1]
array, not shown. Why?
Source code looks like this:
<!DOCTYPE html>
<html>
<head>
<title>Lucas Carvalho</title>
<meta charset="UTF-8">
</head>
<body>
https:<br><br>www.meusite.com.br<br>customer<br>account<br>create<br><br></body>
</html>
Got it, I’d have to do how then? Could you tell me? Other than by /
– Lucas de Carvalho
It depends on what the purpose is. What you want to do?
– Wendel Rodrigues
I need to get EVERYONE on the case. Up to the // there.
– Lucas de Carvalho
Make an if and print a
//
when it is in position 1 of the vector.– Wendel Rodrigues
Just use the parse_url which is a function]suitable for this. @Lucascarvalho
– Daniel Omine
I’ll search Daniel, thank you!
– Lucas de Carvalho
I edited in his reply instead of creating a new answer.
– Daniel Omine
Anyway the
parse_url
will not print the//
which is what you want.– Wendel Rodrigues
I believe that the
//
is indifferent.. once picking up the parts correctly, which is done in parse_url()– Daniel Omine
But that way he’ll have to give one
explode
in thepath
to get what he apparently wants.– Wendel Rodrigues