al/emoji-detector 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

al/emoji-detector

最新稳定版本:0.2.3

Composer 安装命令:

composer require al/emoji-detector

包简介

Detect and return all emoji found in a string

README 文档

README

This library will find all emoji in an input string and return information about each emoji character. It supports emoji with skin tone modifiers, as well as the composite emoji that are made up of multiple people.

Build Status

Installation

composer require al/emoji-detector 

Please take a note: this is fork I created for myself to use this library with updated emoji list. I will try to maintain this fork and update lists. However, if you want additional stability, please use original package: p3k/emoji-detector. Thanks ^^

Usage

Detect Emoji

$input = "Hello ???????? World ????‍????‍????‍????"; $emoji = Emoji\detect_emoji($input); print_r($emoji);

The function returns an array with details about each emoji found in the string.

Array ( [0] => Array ( [emoji] => ????‍????‍????‍???? [short_name] => man-woman-boy-boy [num_points] => 7 [points_hex] => Array ( [0] => 1F468 [1] => 200D [2] => 1F469 [3] => 200D [4] => 1F466 [5] => 200D [6] => 1F466 ) [hex_str] => 1F468-200D-1F469-200D-1F466-200D-1F466 [skin_tone] => ) [1] => Array ( [emoji] => ???????? [short_name] => +1 [num_points] => 2 [points_hex] => Array ( [0] => 1F44D [1] => 1F3FC ) [hex_str] => 1F44D-1F3FC [skin_tone] => skin-tone-3 ) ) 
  • emoji - The emoji sequence found, as the original byte sequence. You can output this to show the original emoji.
  • short_name - The short name of the emoji, as defined by Slack's emoji data.
  • num_points - The number of unicode code points that this emoji is composed of.
  • points_hex - An array of each unicode code point that makes up this emoji. These are returned as hex strings. This will also include "invisible" characters such as the ZWJ character and skin tone modifiers.
  • hex_str - A list of all unicode code points in their hex form separated by hyphens. This string is present in the Slack emoji data array.
  • skin_tone - If a skin tone modifier was used in the emoji, this field indicates which skin tone, since the short_name will not include the skin tone.

Test if a string is a single emoji

Since simply counting the number of unicode characters in a string does not tell you how many visible emoji are in the string, determining whether a single character is an emoji is more involved. This function will return the emoji data only if the string contains a single emoji character, and false otherwise.

$emoji = Emoji\is_single_emoji('????‍????‍????‍????'); print_r($emoji);
Array ( [emoji] => ????‍????‍????‍???? [short_name] => man-woman-boy-boy [num_points] => 7 [points_hex] => Array ( [0] => 1F468 [1] => 200D [2] => 1F469 [3] => 200D [4] => 1F466 [5] => 200D [6] => 1F466 ) [hex_str] => 1F468-200D-1F469-200D-1F466-200D-1F466 [skin_tone] => ) 
$emoji = Emoji\is_single_emoji('????????'); // false

License

Copyright 2017 by Aaron Parecki.

Available under the MIT license.

Emoji data sourced from iamcal/emoji-data under the MIT license.

Emoji parsing regex sourced from EmojiOne under the MIT license.

统计信息

  • 总下载量: 4.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 38
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04