What are some alternatives to using XML for storing hierarchical data in PHP?

Using XML for storing hierarchical data in PHP can be cumbersome and inefficient. One alternative is to use JSON, which is a lightweight data interchange format that is easier to work with in PHP. Another option is to use a relational database like MySQL with a hierarchical data model, or to use a NoSQL database like MongoDB which supports hierarchical data structures.

// Example of storing hierarchical data in JSON format
$data = [
    'name' => 'John',
    'children' => [
        [
            'name' => 'Alice',
            'children' => []
        ],
        [
            'name' => 'Bob',
            'children' => [
                [
                    'name' => 'Charlie',
                    'children' => []
                ]
            ]
        ]
    ]
];

$jsonData = json_encode($data);
echo $jsonData;