T
T
Twelfth Doctor2017-08-10 19:16:58
Windows
Twelfth Doctor, 2017-08-10 19:16:58

How to get multiple rows from an array?

Hello! I have an array like this:

Array
(
    [0] => 
    [1] => animals
    [2] => cats
    [3] => food
    [4] => purina
    [5] => product
    [6] => golden
)

Which I get by converting this string into an array using explode:
/animals/cats/food/purina/product/golden
Question: how do I get links like
/animals
/animals/cats
/animals/cats/food
/animals/cats/food/purina

and link them to the same text (i.e. breadcrumbs from the get request)
/animals/cats/ food / purina
In this case, the URL can be arbitrarily long.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2019-03-28
@zagayevskiy

The code must be written in the head. Well, sometimes help yourself with your hands.

K
Konstantin Malyarov, 2017-08-10
@verdex

foreach($array as $ar){
$string = $string.'/'.$ar;
echo $string;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question