$file = fopen('file.txt', 'r');
if ($file) {
while (($string = fgets($file)) !== false) {
echo $string;
}
fclose($file);
} else {
echo 'Невозможно открыть указанный файл';
}
public function compare( $post1, $post2 ) {
$key = Custom_Rating_Query::$key;
if ( ! $post1 instanceof WP_Post || ! isset( $post1->$key ) ) return 0;
if ( ! $post2 instanceof WP_Post || ! isset( $post2->$key ) ) return 0;
return (int)$post2->$key - (int) $post1->$key;
}
Нужно, что бы каждая ошибка была в отдельном блоке alert
<div class="alert alert-danger" role="alert">
<?echo str_replace("#FIELD_NAME#", """.GetMessage("REGISTER_FIELD_".$key).""", $error);?>
</div>
$s = json_decode($file);
foreach ($s as $t => $k){
echo $k->comment;
echo $k->subtitle;
echo $k->file;
echo $k->poster;
echo '<br>';
}
$xml_str = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<script name="game">
<S time="1389634801" shop="New Moscow Shop" xy="0/-1" city="New Moscow" >
<R name="Metals" cost="1.75" need="41571" />
<R name="Gold" cost="1.1" need="437837" />
<R name="Polymers" cost="1.25" need="301096" />
<R name="Organic" cost="2.6" need="242875" />
<R name="Silicon" cost="1.3" need="909964" />
<R name="Radioactive" cost="2" need="276821" />
<R name="Gems" cost="1.6" need="489296" />
<R name="Venom" cost="0.3" need="252830" />
</S>
<S time="1389634801" shop="Berezka" xy="-1/-1" city="New Moscow" >
<R name="Metals" cost="1.8" need="27183" />
<R name="Gold" cost="1.2" need="14694" />
<R name="Polymers" cost="1.27" need="15719" />
<R name="Organic" cost="2.97" need="17164" />
<R name="Silicon" cost="1.54" need="9195" />
<R name="Radioactive" cost="2.16" need="17663" />
<R name="Gems" cost="1.5" need="17054" />
<R name="Venom" cost="0.37" need="11479" />
</S>
</script>
XML;
$xml = new SimpleXMLElement($xml_str);
echo '<pre>';
echo 'cost:' . $xml->S[0]->R[0]['cost'] . '<br>';
foreach ($xml->S[0]->R as $state => $k) {
echo "name:{$k['name']}
cost:{$k['cost']}
need:{$k['need']}
<br>";
}