⊗ppPmBsND 45 of 447 menu

Accessing Digits of a Number in PHP

Attempting to get a character of a number will cause an error:

<?php $num = 12345; echo $num[0]; // will cause an error ?>

To solve the problem, you can convert our number to a string:

<?php $num = 12345; $str = (string) $num; echo $str[0]; // will output '1' ?>

Given the number 12345. Find the sum of the digits of this number.

Given the number 12345. Find the product of the digits of this number.

Given the number 12345. Rearrange the digits of this number in reverse order.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline