0

Hi,

I'm trying to format an array like this:
[['Apr,2012', 5],['May,2012',10],['Jun,2012',20],['Jul,2012', 13]]

from this:

while ($row = mysql_fetch_assoc($result)) {
            $dates[] = date("M,Y", strtotime($row["Datum"]));
            $data[]   = $row["forsta"];
            }

But I don't know how to combine them in the right format?! Any hints on how to accomplish this?

/Adam

3
Contributors
3
Replies
6
Views
4 Years
Discussion Span
Last Post by adishardis
0

How about this?

while ($row = mysql_fetch_assoc($result)) {
            $dates[] = array(
                             date("M,Y", strtotime($row["Datum"])),
                             $row["forsta"]
                        );
}
2

Something like this:

$data = array ();
while ($row = mysql_fetch_assoc($result)) {
    $data[] = array (
        date("M,Y", strtotime($row['Datum'])), 
        $row['forsta']);
}
echo json_encode($data);
0

That's it, I didn't json encode it!! now it's working with
echo json_encode(($data), JSON_NUMERIC_CHECK)

Thank you so much! :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.