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 460559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:53:09+00:00 2026-05-12T22:53:09+00:00

In CakePHP, it seems like a lot of functions can take their arguments as

  • 0

In CakePHP, it seems like a lot of functions can take their arguments as nested, multidimensional arrays, or as dotted strings:

$this->MyModel->contain(array(
    'Something', 'Something.Else', 'Something.Else.Entirely'
));
$this->MyModel->contain(array(
    'Something' => array(
        'Else' => 'Entirely'
    )
));

Therefore, I figure there must be a function somewhere in the core to switch from dotted to nested associative, but I can’t find it for the life of me. Any ideas?

  • 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-05-12T22:53:09+00:00Added an answer on May 12, 2026 at 10:53 pm

    I’ve actually figured my own way to get this working leveraging the built-in Set functions.

    Given:

    $input = array (
        'Post.id' => 1,
        'Post.title' => 'Some post title.',
        'Post.Tag.0.id' => 4,
        'Post.Tag.0.name' => 'cakephp',
        'Post.Tag.1.id' => 7,
        'Post.Tag.1.name' => 'mysql',
    );
    

    This code will put that into a nested associative array.

    $output = array();
    foreach ($input as $key => $value) {
        $output = Set::insert($output, $key, $value);
    }
    

    Here’s the docs for Set::insert()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm extremely new to CakePHP. From what I've gathered, it seems like I can
This seems like it should be simple, but I'm new to CakePHP. Maybe it's
I realize this seems like an obvious JS type thing - but I'm new
Similar to this question — but due to my ineptitude with CakePHP, I can't
CakePHP has a requireSecure function in the SecurityComponent. I'm using this to force SSL
I am learning cakePHP, everything seems alright except that I am very confused of
I'm just picking up development in CakePHP right now so forgive me if this
I've worked with CakePHP 1.3, but this is my first foray into CakePHP 2.0
I'm building a site with CakePHP which I would like to have 3 sections:
What's the cleanest way to add a prefix to every URL in CakePHP, like

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.