What functions in PHP can be used to pack and unpack binary data for parsing?
When dealing with binary data in PHP, the `pack()` and `unpack()` functions can be used to convert data between binary and human-readable formats. The `pack()` function is used to pack data into a binary string according to a specified format, while the `unpack()` function is used to unpack a binary string into an associative array based on a specified format.
// Example of using pack() and unpack() functions to encode and decode binary data
$data = array('name' => 'John', 'age' => 30);
$format = 'A10name/Cage'; // Define the format for packing/unpacking data
// Pack data into binary string
$binaryData = pack($format, $data['name'], $data['age']);
// Unpack binary string into associative array
$unpackedData = unpack($format, $binaryData);
print_r($unpackedData); // Output the unpacked data