<?php date_default_timezone_set('America/Los_Angeles'); $my_ary_of_objs = ips_to_location(['46.19.37.108', '63.144.78.193', '157.166.226.25']); echo detect_palindrome('mom') ? 'true' : 'false'; echo '<br><br>Reverse of reverse is: ' . str_reverse('reverse') . '<br><br>'; echo has_upper_case('hello') ? 'hello has a capital letter.' : 'hello does\'nt have a capital letter'; echo '<br><br>1442454610 is equal to: ' . make_unix_readable(1442454610) . ' (<em>That\'s in LA time</em>)'; echo '<br><br>the file in this url: http://www.google.com/file.php is: ' . get_file_frm_url('http://www.google.com/file.php'); echo '<br><br>here is the last sentence of the paragraph you\'re reading right now. This one. :' . last_sentence('here is the last sentence of the paragraph you\'re reading right now. This one.'); echo '<br><br>here is the email user for this email: steve@steve.com: ' . email_usr('*****@*****.**'); echo '<br><br>assuming these values are separated by a line break (jack, joe, bill), they\'ll show up as an array below:<br>'; echo '<pre>' . print_r(line_brk_to_ary("jack\njoe\nbill"), true) . '</pre>'; echo '<br><br>here is the data for these ips: 46.19.37.108, 63.144.78.193, 157.166.226.25<br><br>'; echo '<pre>' . print_r($my_ary_of_objs, true) . '</pre>'; echo '<br><br>sorting this up: [3,21,5,\'jack\']. Check it out: ' . '<pre>' . print_r(sort_it_up([3, 21, 5, 'jack']), true) . '</pre>'; echo '<br><br>let\'s try 100 USD to GBP: ' . usd_to(100, 'GBP'); echo '<br><br>let\'s see this table:<br><br>'; echo json_to_table(json_encode($my_ary_of_objs)); //Palindrome detector: function detect_palindrome($word) { $broke_up_wrd = str_split($word); $last_letter = count($broke_up_wrd) - 1; $reverse = []; for ($i = $last_letter; $i >= 0; $i--) { $reverse[] = $broke_up_wrd[$i]; } return $word == implode($reverse); } //Reverse a string
/** * @param callback|null $string * @return callable */ function str_reverse_dg($string = null) { if ($string === null) { $string = tuple_get(0); } return function () use($string) { return str_reverse(call_user_func_array($string, func_get_args())); }; }
<?php /** * resver string */ $string = 'This is not a book!'; print strrev($string); echo PHP_EOL; function str_reverse($str, $i) { return implode($i, array_reverse(explode($i, $str))); } print str_reverse($string, ' ');