mercredi 27 février 2019

if statement in a array

I have a data which im posting using cURL. Now i was wondering if i can pass 2 variables for 1 array.

This is the code that im using to send data

$data = [
    'completion_date'       =>  '31/03/2019',
    'customer_id'           =>  80,
    'full_name'             =>  '',
    'email_address'         =>  'email@email.com',
    'telephone'             =>  '012122212',
    'mobile'                =>  '0787878',
    'address'               =>  'Line 1 address'.chr(10).'Line 2 address',
    'city'                  =>  'City',
    'county'                =>  'County',
    'postcode'              =>  'Postcode',
    'site_company_name'     =>  'Site Company Name',
    'site_full_name'        =>  'Site Contact Name',
    'site_telephone'        =>  '012121212',
    'site_mobile'           =>  '07878787',
    'site_fax'              =>  'Depreciated, not in use',
    'site_email_address'    =>  'email@email.com',
    'site_address'          =>  'Site Line 1 address'.chr(10).'Line 2 address',
    'site_city'             =>  'Site City',
    'site_county'           =>  'Site County',
    'site_postcode'         =>  'Site Postcode',
    'site_notes'            =>  'Site Notes',
    'customer_ref'          =>  $RecordID,
    'wo_ref'                =>  'Customer Job Ref',
    'po_ref'                =>  $OrderID,
    'short_description'     =>  'short description of job',
    'description'           =>  'long description of job',
    'customer_notes'        =>  'Customer notes',
    'job_products'          =>  json_encode($job_products)
];

now i was wondering if i can do something like this

'customer_notes'        =>  $variable1 or $variable2,

what im trying to accomplish is if the $variable1 is empty use data from $variable2 and the other way around. is there a way of doing it or not really ?

'full_name'=> if $var1 empty use $var2

Aucun commentaire:

Enregistrer un commentaire