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