phpsparkpost

SparkPost additional field


I can´t get my head around syntax on line 25 in this SparkPost code - link on github What if I want to add an additional variable to this?

'substitution_data' => ['name' => 'YOUR_FIRST_NAME'],

Say I want to add 'company' => 'ABC'

How should I change the code on line 25 to have multiple variables? Thank you in advance.


Solution

  • substitution_data is an arbitrary list of key/value pairs you can supply and then use in your content or template. In PHP you pass in substitution_data as an associative array. To add more items to it you can do this:

    substitution_data' => [
        'name' => 'YOUR_FIRST_NAME',
        'company' => 'ABC',
    ],
    

    Check out the substitutions reference in the SparkPost docs for more information about substitution data and how to use it.