Results 1 to 2 of 2

Thread: im stuck

  1. #1

    Default im stuck


    Hi gusy its 6 am and been figuring this out for like 2 hours and need help

    i need this to be dynamic any ideas on this

    <?php

    $year = date('Y');
    $month = date('m');

    echo json_encode(array(

    array(
    'id' => 1,
    'title' => "Event1",
    'start' => "$year-$month-10",
    'url' => "http://yahoo.com/"
    ),

    array(
    'id' => 2,
    'title' => "Event2",
    'start' => "$year-$month-20",
    'end' => "$year-$month-22",
    'url' => "http://yahoo.com/"
    )

    ));

    ?>


    the problem is before the second array thers a comma and I can't seem to see like this code.

    its not my code its someone else im trying to make dynamic any ideas?


    Tjhnaks

  2. #2
    What are you trying to do here? Just what exactly do you mean by making it dynamic? Do you want the data be created on the fly? or Do you want dynamic memory allocation in PHP?

    The array you constructed is a mutidimensional array of associative arrays (i.e. an array of hashes).

    If making it dynamic, you mean getting the data somewhere and adding it to the array
    Code:
    $a = array(); // Create an empty array of hashes
    while(<not eof>)
    {
       // read details from file ... 
       ...
       // create an array and populate associative values ...
       $b = array(
            'id' => 1,
            'title' => "Event1",
            'start' => "$year-$month-10",
            'url' => "http://yahoo.com/");
       // Add to the list
       array_push($a, $b); // Same as $a[] = $b;
    }
    ...
    json_encode($a);
    ...
    echo json_encode($c);
    [/code]

  3.    Advertisement

Similar Threads

 
  1. What to do or think when you're stuck in Traffic?
    By beyee in forum General Discussions
    Replies: 1173
    Last Post: 08-14-2019, 02:18 AM
  2. help, im stuck! in PHP programming.
    By emailroy2002 in forum Programming
    Replies: 16
    Last Post: 07-08-2010, 11:43 PM
  3. My wife is in Texas and Im stuck here for another 2 years
    By orcgod in forum General Discussions
    Replies: 12
    Last Post: 03-03-2009, 07:34 AM
  4. splinter cell chaos theory players.. pls help, im stuck.
    By whoopz in forum Software & Games (Old)
    Replies: 5
    Last Post: 10-10-2006, 09:01 AM
  5. Gugmang Giatay: Stay, Leave o Stuck?
    By clashe_11 in forum "Love is..."
    Replies: 80
    Last Post: 08-06-2006, 05:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top