php cheat sheet
배열 길이 얻어오기
count($rows)
형변환
$num = "3.14";
$int = (int)$num;
$myText = (string)$myVar;
오브잭트 -> 스트링
$obj = new MyObject;
echo $obj;
echo serialize($obj);
stdClass 는 Json 을 사용할때도 사용 되기도 한다.
이런식으로 사용해야함.
$lastlogin[0]->FAIL_COUNT
크롬 출력
echo "<script>console.log('".$sql."')</script>";
echo "<script>console.log('1111 ".implode(array_keys($condition))."')</script>";
foreach ($array as $value) {
code to be executed;
}
삼항연산
($value==1)?true:false;
제일 긴 값 가져오기
select * from mytable where length(col_08)=(select max(length(col_08)) from mytable );
json -> 객체
$arr = json_decode($json);
json -> 배열
$arr = json_decode($json, true);
Associative Arrays(연관배열)
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
$age['Peter'] = "35";
$age['Ben'] = "37";
$age['Joe'] = "43";
gettype 반환값
boolean, integer, double, string, array, object, resource, NULL, unknown type
array to string
implode()
implode ( array $pieces ) : string