var hash = window.location.hash;
var selectedOption = null;
if (hash && hash != '#') {
var parts = hash.split('=');
if (parts.length == 2 && parts[0] == "select_option") {
selectedOption = parts[1];
}
}
\DateTime::createFromFormat("d.m.Y в H:i", $dateStr);
$lexems = [
"text" => "TEXT",
];
$data = [];
foreach ($_REQUEST as $k => $v) {
if (array_key_exists($k, $lexems)) {
$data[$k] => htmlspecialchars(trim($v));
}
}
$sourceText = file_get_contents("/path/to/template.txt");
foreach ($data as $k => $v) {
$sourceText = str_replace('{' . $lexems[$k] . '}', $v, $sourceText);
}
echo $sourceText;
label {
display: inline-block;
vertical-align: middle;
width: 45%;
box-sizing: border-box;
}
input:not([type="radio"]) {
display: block;
width: 100%;
}
$show_info = fopen('events/kp1/dungeon1.txt', 'r');
fgets($show_info);
echo fgets($show_info);
fclose($show_info);
function readLine($pathToFile, $index = 0) {
if (!file_exists($pathToFile)) {
return null;
}
$stream = fopen($pathToFile, 'r');
$line = null;
for ($i = 0; $i <= $index; $i++) {
if ($index > 0) {
fgets($stream);
}
if ($i == $index) {
$line = fgets($stream);
}
}
fclose($stream);
return $line;
}
echo readLine('events/kp1/dungeon1.txt', 1); // Выведет вторую строку файла.
class Hook {
protected $callbacks;
public function __construct($callbacks = []) {
$this->callbacks = [];
if (!isset($callbacks) || !is_array($callbacks) || sizeof($callbacks)) {
return;
}
foreach ($callbacks as $k => $v) {
if (!is_string($k) || !isset($v) || !is_callable($v)) {
continue;
}
$this->callbacks[$k] = $v;
}
}
public function add($key, $callback) {
if (!isset($key) || !isset($callback) || !is_string($key) || !is_callable($callback)) {
return;
}
$this->callbacks[$key] = $callback;
}
public function remove($key) {
if ($this->exists($key)) {
unset($this->callbacks[$key]);
}
}
public function exists($key) {
return isset($key) && array_key_exists($key, $this->callbacks);
}
public function run($key, ...$args) {
if ($this->exists($key)) {
$func = $this->callbacks[$key];
if (!isset($args) || !is_array($args)) {
$args = [];
}
if (isset($func)) {
$func(...$args);
}
}
}
}
$hook = new Hook();
$hook->add("my_hook", function ($args) {
// todo
});
$hook->run("my_hook");
$hook->run("my_hook", 1, "string", true);
.menu .menu_item {
border-left: 1px solid #c0c0c0;
}
.menu .menu_item:first-child {
border-left: 0 none;
}
.menu .menu_item {
border-right: 1px solid #c0c0c0;
}
.menu .menu_item:last-child {
border-right: 0 none;
}
mb_convert_encoding()
. Если надо удалить BOM, можно после конвертации в кодировку сделать примерно так:$bom = pack("H*", "EFBBBF");
$string = preg_replace("/^$bom/", '', $string);