You could concatenate in every iteration like :
$tara = 'wordpress/corporate/business';
$k = explode('/', $tara);
$result = "";
foreach ($k as $l) {
$result .= '/'.$l;
echo $result."<br>";
}
The output will be :
/wordpress
/wordpress/corporate
/wordpress/corporate/business
If you don't need the slashes at the start you could add a condition like :
$tara = 'wordpress/corporate/business';
$k = explode('/', $tara);
$result = "";
foreach ($k as $l)
{
if( empty($result) ){
echo $l."<br>";
$result = $l;
}else{
$result .= '/'.$l;
echo $result."<br>";
}
}
Or using the shortened version inside loop with ternary operation, like :
foreach ($k as $l)
{
$result .= empty($result) ? $l : '/'.$l;
echo $result."<br>";
}
The output will be :
wordpress
wordpress/corporate
wordpress/corporate/business