Search
 
SCRIPT & CODE EXAMPLE
 

PHP

palindrome in php

<?php

function palindrome($input) {
    $middle = strlen($input) / 2;
    $firstHalf = substr($input, 0, floor($middle));
    $secondHalf = substr($input, ceil($middle));
    return $firstHalf == strrev($secondHalf);
}

echo palindrome("racecar") ? "Palindrome" : "Not a palindrome";
Comment

PREVIOUS NEXT
Code Example
Php :: aravel 8 how to order by using eloquent orm 
Php :: php echo an array to console 
Php :: continue php 
Php :: search on taxonomy wordpress query 
Php :: message mkdir() invalid path filename drivers/session_files_driver.php 
Php :: php count amount of times a value appears in array 
Php :: send password reset link code wp 
Php :: php import python script 
Php :: php multidimensional array get all values by key 
Php :: laravel collection chunk 
Php :: woocommerce get product categories 
Php :: php number to color 
Php :: php random string 
Php :: symfony password generator command line 
Php :: laravel Command "laravel/ui" is not defined. 
Php :: laravel model is dirty 
Php :: wp debug 
Php :: table has column laravel 
Php :: How can I get current controller and current controller action name in yii2 
Php :: how to use md5 in php 
Php :: laravel new date 
Php :: count words in string php 
Php :: how to delete all products woocommerce in phpmyadmin 
Php :: wherebetween date laravel 
Php :: fetch value from json link in php 
Php :: php or 
Php :: php const 
Php :: select query in php 
Php :: laravel model with methos custom columns 
Php :: save an image use php 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =