search

Home  >  Q&A  >  body text

php - How to express a formula using an array

For example:
Cucumber

The array must be stored in the database, and parameters must be used later to match the calculation results
大家讲道理大家讲道理2842 days ago439

reply all(3)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 12:04:07

    Is this so?

    [
        "items": ["黄瓜" => 10, "萝卜" => 1],
        "total": ["草莓" => 1]
    ]

    When saving to an array, first use json_encode方法转jsonstring

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 12:04:07

    [{
        "cucumber": 10
    },{
        "radish": 10
    },{
        "berries": 10
    }]
    

    or

    
    [{
        "cucumber": 10,
        "radish": 10,
        "berries": 10
    }]

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-16 12:04:07

    // 或者这样?
    [
        {
           cucumber: 10,
           radish: 1,
           Strawberry: 1, 
           result: true
        },
        {
           cucumber: 5,
           radish: 1,
           Strawberry: 1, 
           result: false
        }
    ]

    reply
    0
  • Cancelreply