test - 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 test.php

  1. <?php
  2. $data = [
  3.     "a" => true,
  4.     "b" => false
  5. ];
  6.  
  7. $data['signature'] = generateSignature($data); // return fa0ee1e2acf7f898635ec417491381c0a4f9d35c
  8.  
  9. //send $data like json ...
  10.  
  11. function generateSignature(array $data) {
  12.     $privateKey = 'yourprivatekey';
  13.     ksort($data);
  14.     $implode = multiImplode( ':', $data);
  15.     return sha1($privateKey . md5($implode));
  16. }
  17.  
  18.  
  19. function multiImplode($glue, $array): string
  20.     {
  21.         $finArray = [];
  22.     foreach ($array as $val) {
  23.         $finArray[] = is_array($val) ? self::multiImplode($glue, $val) : $val;
  24.     }
  25.     return implode($glue, $finArray);
  26. }
File Description
  • test
  • PHP Code
  • 08 Sep-2022
  • 604 Bytes
You can Share it: