$string = "Текст1 | {Вложенный1 | Вложенный2 } | Текст2";
preg_match_all('/\s?([^|\{\}]+|\s?\{.+\}\s?)\s?/', $string, $matches);
var_dump($matches[1]);
array(3) {
[0]=>
string(12) "Текст1 "
[1]=>
string(45) "{Вложенный1 | Вложенный2 } "
[2]=>
string(11) "Текст2"
}
<ul>
<?php foreach ($nav_data as $item): ?>
<li>
<a href="<?php echo $item['href'] ?>">
<?php echo $item["title"] ?>
</a>
<?php if (!empty($item['child'])): ?>
<ul class="nav_submenu">
<?php foreach ($item['child'] as $child): ?>
<li class="nav_item">
<a class="nav_link<?php echo $selected == $item['id'] ? ' active' : '' ?>" href="<?php echo $child['href'] ?>">
<?php echo $child["title"] ?>
</a>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
function render($template, $variables) {
extract($variables, EXTR_SKIP);
ob_start();
include $template;
return ob_get_clean();
}
$calendar = array();
foreach ($events as $event) {
$calendar[$event['date_start']] = isset($calendar[$event['date_start']]) ?
$calendar[$event['date_start']] + 1 :
1;
}
function formatSize($bytes)
{
if ($bytes < 1024)
{
return $bytes.' b';
}
elseif ($bytes < 1048576)
{
return round($bytes / 1024, 2).' kb';
}
elseif ($bytes < 1073741824)
{
return round($bytes / 1048576, 2).' mb';
}
elseif ($bytes < 1099511627776)
{
return round($bytes / 1073741824, 2).' gb';
}
elseif ($bytes < 1125899906842624)
{
return round($bytes / 1099511627776, 2).' tb';
}
elseif ($bytes < 1152921504606846976)
{
return round($bytes / 1125899906842624, 2).' pb';
}
else
{
return 'impossible huge!';
}
}
echo basename('http://example/category/category-name1/pagename.html', '.html');
public function doSomething() {
self::_doBeforeSomething();
self::_doSomething();
self::_doAfterSomething();
}