This file contains hidden or 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
| $str = "12345123456712"; #固定長テキスト | |
| @lengths = (5,7,2); #分割する長さの指定 | |
| $format = ''; #フォーマット | |
| #フォーマットの作成 | |
| foreach $length(@lengths) { | |
| $format .= "A$length"; | |
| } | |
| @outs = unpack $format, $str; |
This file contains hidden or 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 | |
| $records = array( | |
| array('name' => '田中 太郎', 'sex' => 1), | |
| array('name' => '田中 花子', 'sex' => 2), | |
| array('name' => '鈴木 太郎', 'sex' => 1), | |
| array('name' => '鈴木 花子', 'sex' => 2) | |
| ); | |
| $filter = create_function('$record', 'return $record["sex"] == 1;'); //1 | |
| $male_only = array_filter($records, $filter); //2 |
NewerOlder