dellemot - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of dellemot.php

  1. <?php
  2.  
  3.  
  4. $json='{"subscription":{"id":"5794a812-baf4-4bb0-9e11-d39cefee0f66","status":"enabled","type":"channel.subscription.message","version":"1","condition":{"broadcaster_user_id":"160237115"},"transport":{"method":"webhook","callback":"https://upaji.net/event/"},"created_at":"2022-04-25T00:19:39.56458387Z","cost":0},"event":{"user_id":"188234755","user_login":"omgeek","user_name":"OMGeeK","broadcaster_user_id":"160237115","broadcaster_user_login":"pajatajna","broadcaster_user_name":"PajaTajna","message":{"text":"pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove pajataLove text na konci","emotes":[{"begin":0,"end":9,"id":"302599635"},{"begin":11,"end":20,"id":"302599635"},{"begin":22,"end":31,"id":"302599635"},{"begin":33,"end":42,"id":"302599635"},{"begin":44,"end":53,"id":"302599635"},{"begin":55,"end":64,"id":"302599635"},{"begin":66,"end":75,"id":"302599635"},{"begin":77,"end":86,"id":"302599635"},{"begin":88,"end":97,"id":"302599635"},{"begin":99,"end":108,"id":"302599635"},{"begin":110,"end":119,"id":"302599635"},{"begin":121,"end":130,"id":"302599635"},{"begin":132,"end":141,"id":"302599635"},{"begin":143,"end":152,"id":"302599635"},{"begin":154,"end":163,"id":"302599635"},{"begin":165,"end":174,"id":"302599635"},{"begin":176,"end":185,"id":"302599635"},{"begin":187,"end":196,"id":"302599635"}]},"tier":"1000","cumulative_months":14,"streak_months":0,"duration_months":0}}';
  5.  
  6.  
  7. $json = json_decode($json, true);
  8.  
  9. function dellemot($text, $json){
  10.     $shift = 0;
  11.     foreach($json['event']['message']['emotes'] as $emote){
  12.         $text = mb_substr($text, 0, $emote['begin'] - $shift) . mb_substr($text, $emote['end'] - $shift + 2);
  13.         $shift += $emote['end'] - $emote['begin'] + 2;
  14.     }
  15.     return $text;
  16. }
  17.  
  18.  
  19. echo dellemot($json["event"]["message"]["text"], $json);
  20.  
  21.  
File Description
  • dellemot
  • PHP Code
  • 16 May-2022
  • 1.89 Kb
You can Share it: