Working with PHP Octals and String conversions

前端 未结 5 799
暖寄归人
暖寄归人 2021-01-13 02:47

I\'m working with a database that has a bunch of serial numbers that are prefixed with leading 0\'s.

So a serial number can look like 00032432 or 56332432.

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-13 03:30

    $serial = 00032432; //here you have an octal number
    $serial= strval($serial); //now you have a string
    if ($serial[0]=="0") {
     //do something
    }
    

提交回复
热议问题