{"id":14454,"date":"2020-06-05T17:05:19","date_gmt":"2020-06-05T17:05:19","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=14454"},"modified":"2021-11-05T10:37:39","modified_gmt":"2021-11-05T10:37:39","slug":"how-to-print-the-number-in-reverse-order-in-php-embedded-in-html-4","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-print-the-number-in-reverse-order-in-php-embedded-in-html-4\/","title":{"rendered":"How to print the number in reverse order in PHP embedded in HTML? -4"},"content":{"rendered":"\n<p>How to print the number in reverse order in PHP?<\/p>\n\n\n\n<p>In this program, you&#8217;ll learn to reverse a number using a while loop.<\/p>\n\n\n\n<p>Logic:<\/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. 3.<\/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 + 3 = 3.<\/li><li>$num is  then divided by 10 so that now it only contains first two digits: 12.<\/li><li>After second iteration, $rem equals 2,&nbsp;<var>$rev<\/var>&nbsp;equals 3 * 10 + 2 = 32 and&nbsp;$<var>num<\/var>&nbsp;= 1.<\/li><li>After third iteration,&nbsp;$rem&nbsp;equals 2,&nbsp;<var>$rev<\/var>&nbsp;equals 32 * 10 + 1 = 321 and&nbsp;$<var>num<\/var>&nbsp;= 0.<\/li><li>Now, $num will be existed outside the while loop and $rev contains 321.<\/li><\/ol>\n\n\n\n<p>Now , look at this coding<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ushakiran27\/ff5e047165c5cab7fbb2686c3b3061e8.js\"><\/script>\n\n\n\n<p>Input : 12345<\/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-6-1024x576.png\" alt=\"\" class=\"wp-image-14455\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-6-1024x576.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-6-300x169.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-6-768x432.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-6-355x199.png 355w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/06\/image-6.png 1366w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Output :54321<\/figcaption><\/figure>\n\n\n\n<p>Thanks<\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_43507\"><iframe loading=\"lazy\"  id=\"_ytid_89570\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_43507\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>How to print the number in reverse order in PHP? In this program, you&#8217;ll learn to reverse a number using a while loop. Logic: First of all, the remainder of&nbsp;$num&nbsp;divided&#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":[1,5150],"tags":[],"class_list":["post-14454","post","type-post","status-publish","format-standard","hentry","category-sql","category-php"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/14454","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=14454"}],"version-history":[{"count":6,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/14454\/revisions"}],"predecessor-version":[{"id":24787,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/14454\/revisions\/24787"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=14454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=14454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=14454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}