PHP 8.5.0 Alpha 4 available for testing

Voting

: max(four, one)?
(Example: nine)

The Note You're Voting On

maiseralves at gmail dot com
14 years ago
<?php
/*
* Struct of a Resource Bundle file
* file root.txt
* root:table {
* usage:string { "Usage: genrb [Options] files" }
* version:int { 122 }
* errorcodes:array {
* :string { "Invalid argument" }
* :string { "File not found" }
* }
* }
* use: $genrb root.txt to generate resource bundle file (root.res)
*/

//recursive function to list a resource bundle file structure using a ResourceBundle Object ( ) reference
function t($rb) {
foreach(
$rb as $k => $v) {
if(
is_object($v)) {
print_r($v);
var_dump($k);
t($v);
} else {
var_dump($k . " " . $v);
}
}
}
//open root.res from folder locale
$rb = new ResourceBundle('root', "./locale");

t($rb);//call the function

/* The output from root table is
* |- string(34) "usage Usage: genrb [Options] files"
* |- string(11) "version 122"
* |- ResourceBundle Object ( ) string(10) "errorcodes"
* |- string(18) "0 Invalid argument"
* |- string(16) "1 File not found"
*/
?>

<< Back to user notes page

To Top