SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    yeeeeeep
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Assigning dynamic variables with =>?

    Hi guys,
    Basically, what I need is to have an array that looks like this.

    $array('title' => $results[1], 'title' => $results[2], 'title' => $results[3])

    How can I do this dynamicallly within a for loop?

    $titles[$i] = 'title' => $results[$i][$model]['Description']; gives me a double arrow error.

    ok, got it! array_combine('title', $results[$i][$model]['Description']) !!


  2. #2
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chaosTheory View Post
    Hi guys,
    Basically, what I need is to have an array that looks like this.

    $array('title' => $results[1], 'title' => $results[2], 'title' => $results[3])
    What do you mean? Array keys should be unique.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    yeeeeeep
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah... seems like that's a problem.

    Are you familiar with cakephp earl?

    I need to use option tag's title... but to pass the information to generate title, i need it in an array....

    back to square one....

    Seems like there's no easy way out of it from cake, i'll echo in the select tag manually..
    So, it's not a problem anymore

    Thanks anyway

  4. #4
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chaosTheory View Post
    Are you familiar with cakephp earl?
    Yeah

    Quote Originally Posted by chaosTheory View Post
    I need to use option tag's title... but to pass the information to generate title, i need it in an array....
    Sorry, still don't understand

  5. #5
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    array_push to add a array to your array perhaps?!
    Code:
    $arr = array();
    array_push($arr, array('title' => $results[1]) );
    array_push($arr, array('title' => $results[2]) );


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •