Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to push (Arrow Function) into array?

I am trying to insert code (double Arrow) into an array. But no matter how I try, I can’t get it to work. My actual attempt is to push the new code to the variable but I’m getting this error:

"syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW)"

What is the right way to add code to that array?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    $shortcode[] = 'attendee_name' => $tickets[0]['shortcode_data']['attendee_name'];
    
    $shortcode = array(
        'product_name'  => $tickets[0]['shortcode_data']['product_name'],
        'start_time'    => $tickets[0]['shortcode_data']['start_time'],
        'end_time'      => $tickets[0]['shortcode_data']['end_time'],
    );

Thanks!

>Solution :

you probably want to just assign to a key:

$shortcode = array(...);

$shortcode['attendee_name'] =  $tickets[0]['shortcode_data']['attendee_name'];
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading