$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\n\t]+/i', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(5) "午�" [3] => string(2) "�" [4] => " [5] => " [6] => string(6) "学習" }
$str = '午前 午後,昼;夜 学習'; $split_arr = preg_split('/[ ;;,,、\r\n\t]+/ui', ' ' . $str); var_dump($split_arr);
実行結果:
array(6) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => string(3) "夜" [5] => string(6) "学習" }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
<a href="/sites/pine/files/field/image/drupal-display-suite-code-field.PNG"><img alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field.PNG" style="height:153px; width:640px"></a> <a href="/sites/pine/files/field/image/drupal-display-suite-code-field-use-token.PNG"><img alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field-use-token.PNG" style="height:390px; width:540px"></a> <a href="/sites/pine/files/field/image/drupal-display-suite-code-field-list.PNG"><img alt="" class="lightbox-show" src="/sites/pine/files/field/image/drupal-display-suite-code-field-list.PNG" style="height:216px; width:640px"></a>
<img alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field.PNG" style="height:153px; width:640px"> <img alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field-use-token.PNG" style="height:390px; width:540px">
<img alt="" class="lightbox-show" src="/sites/pine/files/field/image/drupal-display-suite-code-field-list.PNG" style="height:216px; width:640px">
$pattern="/<img(.+?)>/i"; preg_match_all( $pattern, $html_str, $matches ) ; var_dump($matches); /* 実行結果 */ array(2) { [0] => array(3) { [0] => string(132) "<img alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field.PNG" style="height:153px; width:640px">" [1] => string(142) "<img alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field-use-token.PNG" style="height:390px; width:540px">" [2] => string(159) "<img alt="" class="lightbox-show" src="/sites/pine/files/field/image/drupal-display-suite-code-field-list.PNG" style="height:216px; width:640px">" } [1] => array(3) { [0] => string(127) " alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field.PNG" style="height:153px; width:640px"" [1] => string(137) " alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field-use-token.PNG" style="height:390px; width:540px"" [2] => string(154) " alt="" class="lightbox-show" src="/sites/pine/files/field/image/drupal-display-suite-code-field-list.PNG" style="height:216px; width:640px"" } }
$pattern="/<img(?!.*\"lightbox-show\")(.+?)>/i"; preg_match_all( $pattern, $html_str, $matches ) ; var_dump($matches); /* 実行結果 */ array(2) { [0] => array(2) { [0] => string(132) "<img alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field.PNG" style="height:153px; width:640px">" [1] => string(142) "<img alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field-use-token.PNG" style="height:390px; width:540px">" } [1] => array(2) { [0] => string(127) " alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field.PNG" style="height:153px; width:640px"" [1] => string(137) " alt="" src="/sites/pine/files/field/image/drupal-display-suite-code-field-use-token.PNG" style="height:390px; width:540px"" } }
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" );
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $out_arr = array(); foreach($a as $k =>$var ) { if( $k == "key_3" || $k == "key_4" || $k == "key_5" ) { $out_arr[$k] = $var ; }
$a = array( "key_0" => "val 0", "key_1" => "val one", "key_2" => "val two", "key_3" => "val three", "key_4" => "val four", "key_5" => "val five", "key_6" => "val six" ); $array_keys = array_keys($a); $matched_keys = array_filter( $array_keys, function($k){ return preg_match( "/key_[2-4]/u" , $k) ;} ); foreach($matched_keys as $key){ echo $a[$key]."\n" ; }
array_filter関数の2番目の引数がコールバック関数なので、このコールバック関数に正規表現で特定なキーのマッチングを行っています
$split_arr = preg_split('/[ ;;,,、\n\t]+/ui', ' ' . $str); var_dump($split_arr);
array(7) { [0] => string(0) "" [1] => string(6) "午前" [2] => string(6) "午後" [3] => string(3) "昼" [4] => " [5] => " [6] => string(6) "学習" }