PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function format(string $rawPath): string { preg_match_all('/([^\[;^\]]+)|(\[[^[]+])/', $rawPath, $matches); $groups = reset($matches); if ($groups === false) { $groups = []; } $root = trim((array_shift($groups) ?? ''), '[]'); return array_reduce( $groups, static fn (string $path, string $part): string => ( $path . '[' . trim($part, '[ ]') . ']' ), $root ); } echo format('hello[0]world[1]kiss.log');
Show:  
Copy Clear