class User extends Model {
//...
public function rules(){
return [
//...
[['roles'], 'string'],
[['roles'], 'in', 'range' => User::ROLES],
//...
];
}
//...
}
foreach($city_ids as $value){
$data_file = 'http://export.yandex.ru/weather-ng/forecasts/'.$value.'.xml';
$xml = simplexml_load_file($data_file);
// если $xml не загрузился, то берем из кеша и делаем continue
$xml = objectToArray($xml);
$citys[$value]['station'] = $xml["@attributes"]["city"];
$citys[$value]['temp'] = $xml['fact']['temperature']; //выводим температуру
$citys[$value]['pic'] = $xml['fact']['image-v3']; //выводим пикчакод*/
}
$url = 'http://mydomain.com/news?page=2&checkbox1=1&checkbox3=1';
<input type="checkbox" name="checkbox1" value="1" <?= !empty($_GET['checkbox1']) ? 'checked="checked"' : null ?> />
if (false === Validator::isValidName($_POST['name'])){
$errors['name'] = 'Введите человеческое имя!';
}
<label>
<input type="name" name="name" value="" />
<span class="error"><?= $errors['name'] ?></span>
</label>
$url = 'http://mysite.com/hello/world?look_at=me';
$query = parse_str(parse_url($url, PHP_URL_QUERY));
<a href="?<?= http_build_query(array_merge($query, ['category' => 'val'])) ?>">Категория каталога</a>
<a href="?<?= http_build_query(array_merge($query, ['sort' => 'price'])) ?>">Сортировать по цене</a>