PHP code example of alaa-hany / peplist

1. Go to this page and download the library: Download alaa-hany/peplist library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alaa-hany / peplist example snippets


    use Alaa\PEPlist\Plist;
    use \Alaa\PEPlist\Types\PrimitiveType;
    //$plist = new Plist("<content> </content>" , "path to save (optional)");
    // or 
    //$plist =   Plist::fromFile("PATH/TO/File");
    // or
    $plist =   Plist::createNew();
    
    var_dump($plist->getRootDict()->getLength());
    var_dump($plist->getRootDict()->getChildren());
    /*
     * NV|Node
     * can be
     * 1 ) non object , but should set pType string , data , date if not default is string
     * 2) AbstractType object 
     * 3) DOMNode
     */
    $plist->getRootDict()
    ->insert(["key" => "keyExample" , "NV|Node" => PrimitiveType::createNewPrimitiveElement("string" , "i am string and this my value")])
    ->insert(["key" => "newKey2" , "NV|Node" => "value" , "pType" => "string" ])
    ->insert([
         "key" => "new Arr" ,
         "NV|Node" => \Alaa\PEPlist\Types\Arr::createEmptyArr()->insert(["NV|Node" => "test" ])]);
    $plist->savePretty("test.plist");