0

i've created a complex script for parser datas from XML.

At the end of this, i have this:

     $xmlArray['Event'][$k]['Name event']= $nameVal;    

     $xmlArray['Event'][$k][$i]['Type event']= $typeVal;                              

If i try to parse datas with

     echo '<pre>';
     print_r($xmlArray);
     echo '</pre>';

Seems to be ok.

Now i need to save this data for Wordpress variables. Im trying with this but not works:

foreach($xmlArray as $k => $v){
    if(is_array($v) && count($v) > 0){

        foreach($v as $key => $value){  
        $event = array();
        $name = $value['Name Event']; --> IS OK
        $type = $value[$event][$key]['Type event']; --> Not work, i get error Illegal offset

        echo "$name<br>";           
        echo "$type<br>";           

    }
} else {


}

How can i fix it ??

0

1 Answer 1

1

You're using an empty array as a key:

    $event = array();

    $type = $value[$event][$key]['Type event'];
                   ^^^^^^---array()

Array keys can only be strings or numbers. You can't use an object, you can't use another array, etc..

Sign up to request clarification or add additional context in comments.

2 Comments

$event should be 'Event' I think, based on how s/he keys it originally at the top.
Thanks for Repy, so, how i can save in variables "Type Event" ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.