This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 指定した要素に該当する配列のキーを配列で返す | |
$array = array("blue", "red", "green", "blue", "blue"); | |
print_r(array_keys($array, "blue")); | |
// 指定した要素に該当する配列の最初のキーを返す(数字で) | |
$array = array("blue", "red", "green", "blue", "blue"); | |
print_r(array_search("red", $array) . PHP_EOL); | |
var_dump(array_search("red", $array)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Hoge { | |
public $fuga = 'fuga'; | |
private $bar = 'bar'; | |
function getBar() { | |
return $this->bar; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$hoge = <<<EOT | |
HOGE | |
EOT; // ここにスペースとかあるとうまく作動しない | |
echo $hoge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Hoge { | |
function fuga() { | |
return 'FUGA'; | |
} | |
} | |
$hoge = new Hoge(); | |
$str = <<<EOT | |
{$hoge->fuga()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$date1 = new Datetime('2012-02-01'); | |
$date2 = new Datetime(); | |
$array = $date1->diff($date2); | |
var_dump($array->format('%a') > 40); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'http://d.hatena.ne.jp/shigemk2/20121121/1353496855'; | |
print_r(parse_url($url)); | |
echo parse_url($url); | |
/* | |
* Array | |
* ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title>HOGE</title> | |
<style type="text/css"> | |
body { | |
background-color: rgba(255,0,0,.5); | |
} | |
div.hoge { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$date = new DateTime('2000-01-20'); | |
$date->sub(new DateInterval('P12M')); // 12ヶ月前 | |
echo $date->format('Y-m-d') . "\n"; // 1999-01-20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$t = new DateTime(); | |
print_r($t); | |
/* | |
DateTime Object | |
( | |
[date] => 2013-01-13 14:54:37 | |
[timezone_type] => 3 | |
[timezone] => Asia/Tokyo | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('ABCDEFGHIJKLMNOP'.slice(-5)); // LMNOP | |
console.log('ABCDEFGHIJKLMNOP'.slice(-10)); // GHIJKLMNOP |