Recently i am making a google map shortcode where my javascript code need to store in a variable.
This is my code where I append my java script code in a php variable but it shows me Undefined index: lng cant find out the

if ( is_array( $GLOBALS['long_lat'] ) ) {
            $markerfunc = '';
                foreach ($GLOBALS['long_lat'] as $item ) {
                    $markerfunc .= 'map.addMarker({
                                lat: '.$item['lat'].',
                                lng: '.$item['lng'].',
                                title: '.$item['title'].',
                                infoWindow: {
                                  content: "<p>'.$item['body'].'</p>"

Read more here: Need to store javascript function in php variable but Notice: Undefined index: on variable [duplicate]


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: