1. substr_count()

ex)

echo substr_count($story, "like"); // Prints: 8

문장에 해당 단어가 몇개 있는지 표시하는 함수

2. strrev()

ex)

echo strrev("Hello, World!"); // Prints: !dlroW ,olleH

문장을 거꾸로 표시하는 함수

3. strtolower() strtoupper()

ex

echo strtolower("HeLLo"); // Prints: hello

해당 부분을 소문자로

4. str_repeat()

echo str_repeat("hi", 10); // Prints: hihihihihihihihihihi 

해당 부분을 반복해서 표시

Number Functions

1.

function calculateDistance($first, $second)
{
  return abs($first - $second);
}

2.

function calculateTip($cost_of_a_meal)
{
  return round($cost_of_a_meal * 1.18);
}

echo calculateTip(100);

3.

$max = getrandmax(); 
 
echo $max;

echo rand(); // Prints a number between 0 and $max
echo rand(1,52); // Prints a number between 1 and 52

echo rand(1, 52); 은 1과 52사이에 숫자중 하나를 랜덤으로 뽑는다.

4. Documentation

str_pad ( string $input , int $pad_length [, string $pad_string = " " [, int $pad_type = STR_PAD_RIGHT ]] ) : string

str_pad ( string $input , int $pad_length [, string $pad_string = " " [, int $pad_type = STR_PAD_RIGHT ]] ) : string

5. Ceil 올림

6.

function calculateCircleArea($diameter)
{
  return pi() * ($diameter/2)**2;
}
profile
A to z

0개의 댓글