minte9
LearnRemember / PHP



Character

ord() - Return ASCII value of character chr() - Return character by ASCII code
 
echo ord("A"); // 65
echo chr(65); // A

Number

number_format() - is not locale-aware, and returns a rounded number
 
echo number_format("100000.698"); // 100,001 
echo number_format("100000.698", 3, ",", " "); // 100 000,698

Pad

str_pad() - Pad a string to a certain length with another string
     
echo str_pad("100", 6, "0"); // 100000
echo str_pad("333", 6, "0", STR_PAD_LEFT); // 000333






Questions and answers




Which function returns the character A?

  • a) chr(65)
  • b) ord(65)

How do you obtain the string "000333" from 333?

  • a) str_pad("333", 6, "0", STR_PAD_LEFT)
  • b) str_pad("333", "0", 3)


References