PROGRAMMING

  MINTE9
REMEMBERS




Last update:   29-10-2021

Serialize

Generates a storable representation of an array (or object)
 
$data = array(
    'name' => 'Smith',
    'age' => 30,
);

echo $encoded = serialize($data);
    // a:2:{s:4:"name";s:5:"Smith";s:3:"age";i:30;}

$data = unserialize($encoded);
print_r($data); 
    // [name] => Smith [age] => 30

Json

Encode returns a string containing the json representation.
 
$arr = ['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)[3]
        'a' => int 1
        'b' => int 2
        'c' => int 3
*/

Parse ini

Parse a configuration file conf.ini
 
/* 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    
String basics
        A B C D E F
🔔
1/2