PHP Code simplest example function SplitOnFirstUnique($s){ $len = strlen($s); $output = []; $newstring = ''; for ($i=0; $i < $len ; $i++) { $newstring = $newstring.$s[$i]; if(!in_array($s[$i] , $output )){ $output[] = $newstring; $newstring = ''; } } return $output; }