From 94e35215d24110c2dc3c3c7518d4d6217f5a89d9 Mon Sep 17 00:00:00 2001 From: Sebastian Korotkiewicz Date: Thu, 24 Mar 2022 21:00:32 +0100 Subject: [PATCH] bionic lib --- bionic.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bionic.php diff --git a/bionic.php b/bionic.php new file mode 100644 index 0000000..dfe47c9 --- /dev/null +++ b/bionic.php @@ -0,0 +1,38 @@ +" . substr($word, 0, 1) . "" . substr($word, 1); + + } elseif ( $count == 4 ) { + // If there are == 4 letters, two letters are bold. + return "" . substr($word, 0, 2) . "" . substr($word, 2); + + } elseif ( $count > 4 ) { + // If there are > 4 letters, 40% of all letters are bold. + $ch = $count / 100 * 40; + $c = (int)$ch; + return "" . substr($word, 0, $c) . "" . substr($word, $c); + + } else { + return $word; + } +} + + +$output = array_map(function($word) { + $word = preg_replace_callback('/\w+/i', 'style', $word); + return $word; +}, $arr); + + +echo join($output, " "); + +?> \ No newline at end of file