Memory App
Programming
 




Serialize

Generates a storable representation of an array (or object)

$data = array(
    'firstname' => 'John',
    'name' => 'Smith',
    'age' => 30,
);

echo $string = serialize($data);

// a:3:{s:9:"firstname";s:4:"John";s:4:"name";s:5:"Smith";s:3:"age";i:30;}

$result = unserialize($string);

// [firstname] => John [name] => Smith [age] => 30
(1/3)

Json decode

Returns a string containing the json representation

$arr = array('a' => 1, 'b' => 2, 'c' => 3);

echo $json = json_encode($arr); // {"a":1,"b":2,"c":3}

$arr2 = json_decode($json);

var_dump($arr2);
/*
    object(stdClass)[1]
        public 'a' => int 1
        public 'b' => int 2
        public 'c' => int 3
*/    
(2/3)

Parse ini file

Parse a configuration file conf.ini

/* 
url_base = "api.com/RestApi/v1/"
ssl_verifyhost = 2
ssl_verifypeer = true
auth_type = "token"
auth_method = "Authentication/RequestToken"
*/

$conf = parse_ini_file(__DIR__ . '/inc/conf.ini');


Questions



Top Reference > Programming
0/0 (80)  
Not Logged