Wrong usage of preg_match_all - 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.

Name: Wrong usage of preg_match_all fullscreencopydownloadembedprint


Your result can be seen below.

Result of php executing





Full code of Wrong usage of preg_match_all.php

  1. <?php
  2. $text = 'Bitte akzeptieren Sie die Datenschutzerklärung';
  3. $langSamples = [
  4.     'Please accept the Privacy Agreement' => 'Bitte akzeptieren Sie die Datenschutzerklärung',
  5.     'Date' => 'Datum',
  6. ];
  7.  
  8. foreach ($langSamples as $key => $value) {
  9.     if (!preg_match_all("/" . $key . "/", $text, $variables)) {
  10.         continue;
  11.     }
  12.     var_dump($variables);
  13. }
  14.  
File Description
  • Wrong usage of preg_match_all
  • PHP Code
  • 21 Apr-2022
  • 365 Bytes
You can Share it: