<?php
// $output = array_slice(array_merge(explode(' | ', $input), array(null)), 0, 2);
$input = 'one';
$output = array_slice(explode(" | ", "$input | "), 0, 2);
print_r($output);
$input = 'one | two';
$output = array_slice(explode(" | ", "$input | "), 0, 2);
print_r($output);
$input = 'one | two | three';
$output = array_slice(explode(" | ", "$input | "), 0, 2);
print_r($output);
$input = 'one | two | three | ';
$output = explode(" | ", "$input | ")[0][1];
print_r($output);
preferences:
42.41 ms | 402 KiB | 5 Q