dimanche 22 juillet 2018

add value to each month array

i have a set of branch which looping. i wanna add report section just like json output below..i'm using laravel as my json API..

branch result come from database.

$month  = array("January","February","March","April","May","June","July","August","September","October","November","December");

this is my expected output after process

{
"res": true,
"branch": [{
        "com_branch_id": 7,
        "report": {
            "January": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "Febuary": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "March": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "April": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "May": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "Jun": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "July": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "August": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "September": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "October": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "November": {
                "totalSales": "400",
                "Profit": "1000"
            },
            "December": {
                "totalSales": "400",
                "Profit": "1000"
            }
        }
    },

]

}

hope someone can help solved this problem..thanks..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire