Fork me on GitHub

#1 2015-10-12 18:36:59

lavvaf
Member
Registered: 2015-10-09
Posts: 29

Help me to Understand!

Hi Everyone!

I'm looking to understand red lines in this section:

$config = um('getCurrentUserDir').'/'.CONF_USER_DIR.'/eyeDesk/conf.xml';
    $xml = eyeXML('getXMLfile',array($config));
    $autorun = $xml['eyeDesk'][0]['autolaunch'];
   
    for($i=0;$i < count($autorun);$i++) {
        if($autorun[$i] == 'sample-name'){
            $activado = true;
            break;
        }
    }
    if (!$activado) {
        $xml['eyeDesk'][0]['autolaunch'][($i + 1)] = 'sample-name';
        eyeXML('setXMLfile',array($config,$xml));
    }

Please help me!
Thanks a lot

Offline

#2 2015-10-13 07:51:50

lavvaf
Member
Registered: 2015-10-09
Posts: 29

Re: Help me to Understand!

Please help me to understand how to read/write in XML file with array!
what is the meaning of:

$xml['eyeDesk'][0]['autolaunch'][($i + 1)]

Offline

#3 2015-10-13 16:13:50

lavvaf
Member
Registered: 2015-10-09
Posts: 29

Re: Help me to Understand!

any help????

Offline

#4 2015-10-13 23:30:53

lars-sh
Administrator
From: near Hamburg, Germany
Registered: 2011-07-14
Posts: 731
Website

Re: Help me to Understand!

Using "[]" on arrays allows you to append a new element. That rest seems fine, even though I recommend you to use "getXMLconfig" as described at http://forums.oneye-project.org/viewtopic.php?id=663 to read and "setXMLconfig" to write those configurations.

$xml['eyeDesk'][0]['autolaunch'][] = 'sample-name';

One more tip: Better initialize "$activado" with "false" before entering that loop.


Best regards,
Lars Knickrehm

The oneye project.

Offline

#5 2015-10-14 13:47:35

lavvaf
Member
Registered: 2015-10-09
Posts: 29

Re: Help me to Understand!

Dear Lars,
Thanks for your information.

Offline

Board footer

Powered by FluxBB