Answer the question
In order to leave comments, you need to log in
What is the best way to trim the contents of a variable?
Hello. What is the best way to bring the variable to the desired form? The variable $a="/store/bokal/skatert-velvet9/" needs to be cut to the form $b="/store/bokal/
I have an idea to do this:
$a = "/store/bokal/skatert-velvet9/";
list($one $two,three) = explode("/", $a);
$url = "/"."$two"."/"."$three"."/";
echo $url;
Answer the question
In order to leave comments, you need to log in
Could it be something like this
$a = "/store/bokal/skatert-velvet9/";
$exp = explode("/", $a);
$url = "/{$exp[1]}/{$exp[2]}/";
echo $url;
$a="/store/bokal/skatert-velvet9/";
$a= str_replace('/store', '', $a);
$a = "/store/bokal/skatert-velvet9/";
$l = explode("/", trim($a, '/'));
$url = "/$l[0]/$l[1]/";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question