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

How about this?

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

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);

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! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.