{"id":14497,"date":"2020-06-06T13:22:36","date_gmt":"2020-06-06T13:22:36","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=14497"},"modified":"2020-06-06T13:45:27","modified_gmt":"2020-06-06T13:45:27","slug":"how-to-check-the-given-number-is-either-palindrome-number-or-not-in-php-embedded-in-html-5","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-check-the-given-number-is-either-palindrome-number-or-not-in-php-embedded-in-html-5\/","title":{"rendered":"How to check the given number is either Palindrome number or not in PHP embedded in HTML? -5"},"content":{"rendered":"\n<p>How to check the given number is either Palindrome number or not in PHP?<\/p>\n\n\n\n<p>What is the Palindrome number?<\/p>\n\n\n\n<p>A palindrome is a word , number, phrase, verse or sentence that reads the same forward and backward.<\/p>\n\n\n\n<p>Here , we&#8217;ll see the palindrome number:<\/p>\n\n\n\n<p><strong>Logic<\/strong>: Its logic has same like reverse number, in further we&#8217;ll check the given number and reverse number is equal or not.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>First of all, the remainder of&nbsp;<var>$num<\/var>&nbsp;divided by 10 is stored in the variable&nbsp;$rem. Now,&nbsp;$rem contains the last digit of&nbsp;$num, i.e. 1.<\/li><li>$rem is then added to the variable $rev after multiplying it by 10.<\/li><li>Multiplication by 10 adds a new place in the $rev contains. $rev contain like this 0 * 10 + 1 = 1.<\/li><li>$num is  then divided by 10 so that now it only contains first four digits: 1232.<\/li><li>After second iteration, $rem equals 2,&nbsp;<var>$rev<\/var>&nbsp;equals 1 * 10 + 2 = 12 and&nbsp;$<var>num<\/var>&nbsp;= 123.<\/li><li>After third iteration,&nbsp;$rem&nbsp;equals 3,&nbsp;<var>$rev<\/var>&nbsp;equals 12 * 10 + 3 = 123 and&nbsp;$<var>num<\/var>&nbsp;= 12.<\/li><li>After fourth iteration,&nbsp;$rem&nbsp;equals 2,&nbsp;<var>$rev<\/var>&nbsp;equals 123 * 10 + 2 = 1232 and&nbsp;$<var>num<\/var>&nbsp;= 1.<\/li><li>After fifth iteration,&nbsp;$rem&nbsp;equals 1,&nbsp;<var>$rev<\/var>&nbsp;equals 1232 * 10 + 1 = 12321 and&nbsp;$<var>num<\/var>&nbsp;= 0.<\/li><li>Now, $num will be existed outside the while loop and $rev contains 12321.<\/li><\/ol>\n\n\n\n<p>Now , look at this coding<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ushakiran27\/413f0bfc4e470669ae887df31d32099d.js\"><\/script>\n\n\n\n<p>The input number is: 12321<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-8-1024x576.png\" alt=\"\" class=\"wp-image-14504\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-8-1024x576.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-8-300x169.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-8-768x432.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-8-355x199.png 355w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-8.png 1366w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>12321 is the palindrome number.<\/figcaption><\/figure>\n\n\n\n<p>Another input is 1234:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-9-1024x576.png\" alt=\"\" class=\"wp-image-14505\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-9-1024x576.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-9-300x169.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-9-768x432.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-9-355x199.png 355w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-9.png 1366w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>1234 is not palindrome number<\/figcaption><\/figure>\n\n\n\n<p>Thanks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to check the given number is either Palindrome number or not in PHP? What is the Palindrome number? A palindrome is a word , number, phrase,&#8230; <\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5150],"tags":[],"class_list":["post-14497","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/14497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=14497"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/14497\/revisions"}],"predecessor-version":[{"id":14508,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/14497\/revisions\/14508"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=14497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=14497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=14497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}