Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Split a string by a string
<?php explode(string $separator, string $string, int $limit = PHP_INT_MAX): array
<?php public function find(array $match): string {
$splitted_conditional = explode(self::getTag(self::TAG_IF), $match['x']);
$condition = trim($splitted_conditional[0]);
$rendered_condition = $this->doOpreration($condition);
$splitted_if_else = explode(self::getTag(self::TAG_ELSE), $splitted_conditional[1]);
<?php $splitted_conditional = explode(self::getTag(self::TAG_IF), $match['x']);
$condition = trim($splitted_conditional[0]);
$rendered_condition = $this->doOpreration($condition);
$splitted_if_else = explode(self::getTag(self::TAG_ELSE), $splitted_conditional[1]);
$ifTrue = trim($splitted_if_else[0] ?? '');
$ifFalse = trim($splitted_if_else[1] ?? '');
return $this->getCore()->render($rendered_condition ? $ifTrue : $ifFalse);
<?php private function doOpreration(string $condition): bool|string|int {
$operators = ['\={3}', '\={2}', '\!\={2}', '\!\={1}', '\<\=\>', '\>\=', '\<\=', '\<\>', '\>', '\<', '%', '&{2}', '\|{2}', 'xor', 'and', 'or'];
if (preg_match('/.+\s*(' . implode('|', $operators) . ')\s*.+/U', $condition, $matches)) {
$a_and_b = explode($matches[1], $condition);
$a = trim($this->getCore()->render($a_and_b[0]));
$b = trim($this->getCore()->render($a_and_b[1]));
return self::evaluateOperation($a, $matches[1], $b);
<?php private function getFunctionAndArguments(string $filter): array {
$parts = explode(self::getTag(self::TAG_ARGUMENT), $filter);
return [$this->getFilter($parts[0]), isset($parts[1]) ? explode(self::getTag(self::TAG_ARGUMENT_LIST), $parts[1]) : []];
}
<?php private function getFunctionAndArguments(string $filter): array {
$parts = explode(self::getTag(self::TAG_ARGUMENT), $filter);
return [$this->getFilter($parts[0]), isset($parts[1]) ? explode(self::getTag(self::TAG_ARGUMENT_LIST), $parts[1]) : []];
}
<?php $tag_chain = self::getTag(self::TAG_CHAIN);
$key_pattern = self::patternCache($core->getPHPlaterObject(self::CLASS_KEY));
$tag_list = $tag_chain . $tag_chain;
$all_before_parts = explode($tag_list, $matches['x'][0]);
$tag_last = end($all_before_parts) === '' ? '' : $tag_chain;
$tag_first = reset($all_before_parts) === '' ? '' : $tag_chain;
$core_parts = explode($tag_chain, $all_before_parts[0]);
<?php $all_before_parts = explode($tag_list, $matches['x'][0]);
$tag_last = end($all_before_parts) === '' ? '' : $tag_chain;
$tag_first = reset($all_before_parts) === '' ? '' : $tag_chain;
$core_parts = explode($tag_chain, $all_before_parts[0]);
$elements = '';
$list = self::getList($core->getPlates(), $core_parts);
foreach ($list as $key => $item) {
<?php private static function getFiltersAndParts(string $plate): array {
$parts = []; //gives error or wrong result if this is []
if (str_contains($plate, self::getTag(self::TAG_FILTER))) {
$parts = explode(self::getTag(self::TAG_FILTER), $plate);
$plate = array_shift($parts);
}
$chain = [$plate];
<?php }
$chain = [$plate];
if (str_contains($plate, self::getTag(self::TAG_CHAIN))) {
$chain = explode(self::getTag(self::TAG_CHAIN), $plate);
}
return [$chain, $parts];
}