Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:57:28+00:00 2026-06-12T23:57:28+00:00

If you downvote my question, please be KIND enough to leave a reason Hey

  • 0

If you downvote my question, please be KIND enough to leave a reason

Hey guys I got a little snip that will take a structure of urls like so

// brevity
[182] => Array
    (
        [path] => /home-phone/troubleshooting
        [name] => Troubleshooting
    )

[183] => Array
    (
        [path] => /home-phone/troubleshooting/my-voicemail-to-e-mail-feature-is-not-working
        [name] => My Voicemail to E-mail feature is not working.
    )

[184] => Array
    (
        [path] => /home-phone/troubleshooting/when-i-receive-my-voicemail-by-e-mail-i-cannot-hear-the-message
        [name] => When I receive my voicemail by e-mail, I cannot hear the message.
    )

[185] => Array
    (
        [path] => /home-phone/troubleshooting/i-don-t-hear-a-dial-tone-when-i-pick-up-my-phone
        [name] => I don't hear a dial tone when I pick up my phone.
    )

[186] => Array
    (
        [path] => /home-phone/troubleshooting/i-moved-my-voice-adapter-and-can-no-longer-make-or-receive-calls
        [name] => I moved my Voice adapter and can no longer make or receive calls.
    )

[187] => Array
    (
        [path] => /home-phone/troubleshooting/my-call-waiting-is-not-working-since-i-forwarded-voice-to-another-line
        [name] => My call waiting is not working since I forwarded Voice to another line.
    )

[188] => Array
    (
        [path] => /home-phone/troubleshooting/i-m-unable-to-complete-transactions-on-ivr-phone-calls-like-online-banking
        [name] => I'm unable to complete transactions on IVR phone calls (like online banking).
    )

[189] => Array
    (
        [path] => /home-phone/troubleshooting/i-can-t-get-a-dial-tone-and-i-could-before
        [name] => I can't get a dial tone (and I could before).
    )

[190] => Array
    (
        [path] => /home-phone/troubleshooting/im-not-getting-my-voicemail-to-e-mail-messages
        [name] => I'm not getting my Voicemail to E-mail messages.
    )

[191] => Array
    (
        [path] => /home-phone/troubleshooting/my-caller-id-has-not-worked-since-i-forwarded-my-voice-line-to-another-phone-line
        [name] => My Caller ID has not worked since I forwarded my Voice line to another phone line.
    )

[192] => Array
    (
        [path] => /home-phone/troubleshooting/im-having-trouble-sending-andor-receiving-a-fax
        [name] => I'm having trouble sending and/or receiving a FAX.
    )
// brevity

And turn them into a multidim array, like this

[4] => home-phone
[home-phone] => Array
    (

// brevity

        [9] => troubleshooting
        [troubleshooting] => Array
            (
                [0] => my-voicemail-to-e-mail-feature-is-not-working
                [1] => when-i-receive-my-voicemail-by-e-mail-i-cannot-hear-the-message
                [2] => i-don-t-hear-a-dial-tone-when-i-pick-up-my-phone
                [3] => i-moved-my-voice-adapter-and-can-no-longer-make-or-receive-calls
                [4] => my-call-waiting-is-not-working-since-i-forwarded-voice-to-another-line
                [5] => i-m-unable-to-complete-transactions-on-ivr-phone-calls-like-online-banking
                [6] => i-can-t-get-a-dial-tone-and-i-could-before
                [7] => im-not-getting-my-voicemail-to-e-mail-messages
                [8] => my-caller-id-has-not-worked-since-i-forwarded-my-voice-line-to-another-phone-line
                [9] => im-having-trouble-sending-andor-receiving-a-fax
            )

// brevity

    )

Works pretty good, but I got to the end and realized I’d lost all my Names
(your can see theirs a second column for names), I left a spacer for a Name,
but for the life of me can’t figure out how to get it in there now =(

Any ideas?

EDIT forgot my source code 😉

    $tree = array();
    foreach($indexArray as $branch) {

        $limb = explode('/', $branch['path']);

        $subTree = array(array_pop($limb));
        foreach (array_reverse($limb) as $dir) {
            $subTree = array($dir => $subTree);
        }

        $tree = array_merge_recursive($tree, $subTree);

    }

Expected output should be

[Home Phone] => home-phone
[home-phone] => Array
    (

// brevity

        [Troubleshooting] => troubleshooting
        [troubleshooting] => Array
            (
                [My Voicemail to E-mail feature is not working.] => my-voicemail-to-e-mail-feature-is-not-working
                [When I receive my voicemail by e-mail, I cannot hear the message.] => when-i-receive-my-voicemail-by-e-mail-i-cannot-hear-the-message
                [I don't hear a dial tone when I pick up my phone.] => i-don-t-hear-a-dial-tone-when-i-pick-up-my-phone

                // etc

            )

// brevity

    )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:57:29+00:00Added an answer on June 12, 2026 at 11:57 pm

    Since you did not put expected output am working on assumption .. you can try :

    $data = array();
    $i = 0 ;
    foreach ( $array as $key => $value ) {
        $temp = array();
        setPath($temp,dirname($value['path']) . "/$i/path", basename($value['path']));
        setPath($temp, dirname($value['path']) . "/$i/name", $value['name']);
        $data = array_merge_recursive($data, $temp);
        $i ++;
    }
    
    echo "<pre>";
    print_r($data);
    

    Output

    Array
    (
        [home-phone] => Array
            (
                [path] => troubleshooting
                [name] => Troubleshooting
                [troubleshooting] => Array
                    (
                        [1] => Array
                            (
                                [path] => my-voicemail-to-e-mail-feature-is-not-working
                                [name] => My Voicemail to E-mail feature is not working.
                            )
    
                        [2] => Array
                            (
                                [path] => when-i-receive-my-voicemail-by-e-mail-i-cannot-hear-the-message
                                [name] => When I receive my voicemail by e-mail, I cannot hear the message.
                            )
    
                        [3] => Array
                            (
                                [path] => i-don-t-hear-a-dial-tone-when-i-pick-up-my-phone
                                [name] => I don't hear a dial tone when I pick up my phone.
                            )
    
                        [4] => Array
                            (
                                [path] => i-moved-my-voice-adapter-and-can-no-longer-make-or-receive-calls
                                [name] => I moved my Voice adapter and can no longer make or receive calls.
                            )
    
                        [5] => Array
                            (
                                [path] => my-call-waiting-is-not-working-since-i-forwarded-voice-to-another-line
                                [name] => My call waiting is not working since I forwarded Voice to another line.
                            )
    
                        [6] => Array
                            (
                                [path] => i-m-unable-to-complete-transactions-on-ivr-phone-calls-like-online-banking
                                [name] => I'm unable to complete transactions on IVR phone calls (like online banking).
                            )
    
                        [7] => Array
                            (
                                [path] => i-can-t-get-a-dial-tone-and-i-could-before
                                [name] => I can't get a dial tone (and I could before).
                            )
    
                        [8] => Array
                            (
                                [path] => im-not-getting-my-voicemail-to-e-mail-messages
                                [name] => I'm not getting my Voicemail to E-mail messages.
                            )
    
                        [9] => Array
                            (
                                [path] => my-caller-id-has-not-worked-since-i-forwarded-my-voice-line-to-another-phone-line
                                [name] => My Caller ID has not worked since I forwarded my Voice line to another phone line.
                            )
    
                        [10] => Array
                            (
                                [path] => im-having-trouble-sending-andor-receiving-a-fax
                                [name] => I'm having trouble sending and/or receiving a FAX.
                            )
    
                    )
    
            )
    
    )
    

    Function Used

    function setPath(&$temp, $url, $value) {
        foreach ( array_filter(explode("/", $url)) as $key ) {
            $temp = &$temp[$key];
        }
        $temp = $value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please dont downvote the question because of the fact that the answer Im looking
Before downvote please read the question, I also see other question but doesn't find
First of all; I'm aware that this question is strange and I will probably
This is a very newbie question and i will probably get downvoted for it,
I have a little question. say i have a js function $(function() { $(.button).click(function(){
Ok I don't want this to be a hacking advice question, so please don't
[@the downvote and idiot remarks, that's not cool to beat up on people. I
Yesterday, I asked this question and never really got an answer I was really
I want to set a cron job that will execute every 15 minutes. Before
I am making my own MVC framework (please do not downvote me because everyone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.