Skip to content

Instantly share code, notes, and snippets.

@godismyjudge95
Last active February 20, 2025 22:32
Show Gist options
  • Select an option

  • Save godismyjudge95/3ef849b6558416e098e0251445d5ed5a to your computer and use it in GitHub Desktop.

Select an option

Save godismyjudge95/3ef849b6558416e098e0251445d5ed5a to your computer and use it in GitHub Desktop.
<?php
function sliceAtUTF8Boundary(string $input): string
{
preg_match_all("/\X/u", $input, $matches);
return implode("", array_splice($matches[0], 0, -1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment