{"id":798,"date":"2025-08-04T16:21:03","date_gmt":"2025-08-04T07:21:03","guid":{"rendered":"https:\/\/nexive.tech\/?p=798"},"modified":"2025-08-04T16:21:03","modified_gmt":"2025-08-04T07:21:03","slug":"%e3%80%90%e3%82%b5%e3%82%af%e3%83%83%e3%81%a8%e8%a7%a3%e8%aa%ac%e3%80%91php-%e3%83%87%e3%82%a3%e3%83%ac%e3%82%af%e3%83%88%e3%83%aa%e5%86%85%e3%81%ae%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e4%b8%80","status":"publish","type":"post","link":"https:\/\/nexive.tech\/?p=798","title":{"rendered":"\u3010\u30b5\u30af\u30c3\u3068\u89e3\u8aac\u3011PHP \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u4e3b\u8981\u306a\u65b9\u6cd5\u3092\u7d39\u4ecb<\/li>\n\n\n\n<li><code>scandir<\/code>\u3001<code>glob<\/code>\u3001<code>DirectoryIterator<\/code> \u306e\u4f7f\u3044\u5206\u3051\u3092\u5177\u4f53\u7684\u306b\u89e3\u8aac<\/li>\n\n\n\n<li>\u5b9f\u52d9\u3067\u306e\u7528\u9014\u3084\u6ce8\u610f\u70b9\u3082\u542b\u3081\u3001\u8aa4\u7528\u3057\u3084\u3059\u3044\u30d1\u30bf\u30fc\u30f3\u3082\u88dc\u8db3<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. PHP\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>PHP\u3067\u306f\u3001\u6307\u5b9a\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306b\u5b58\u5728\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3084\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u3084\u30af\u30e9\u30b9\u304c\u8907\u6570\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u306f\u3001\u30ed\u30b0\u51fa\u529b\u5148\u306e\u4e00\u89a7\u53d6\u5f97\u3084\u3001\u753b\u50cf\u30d5\u30a9\u30eb\u30c0\u306e\u52d5\u7684\u8aad\u307f\u8fbc\u307f\u3001\u30d0\u30c3\u30c1\u51e6\u7406\u3067\u306e\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\u9078\u5b9a\u306a\u3069\u3001\u591a\u304f\u306e\u5834\u9762\u3067\u4f7f\u308f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee3\u8868\u7684\u306a\u65b9\u6cd5\u306b\u306f\u3001\u30b7\u30f3\u30d7\u30eb\u306a<code>scandir<\/code>\u95a2\u6570\u3001\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u304c\u4f7f\u3048\u308b<code>glob<\/code>\u95a2\u6570\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3067\u6271\u3048\u308b<code>DirectoryIterator<\/code>\u30af\u30e9\u30b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3089\u306f\u4e00\u898b\u4f3c\u305f\u76ee\u7684\u306b\u898b\u3048\u307e\u3059\u304c\u3001\u67d4\u8edf\u6027\u3084\u51e6\u7406\u52b9\u7387\u3001\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u306e\u3057\u3084\u3059\u3055\u306b\u9055\u3044\u304c\u3042\u308b\u305f\u3081\u3001\u7528\u9014\u306b\u5fdc\u3058\u305f\u9078\u5b9a\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u8a73\u7d30\u89e3\u8aac<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u57fa\u672c\u7684\u306a\u65b9\u6cd5\uff1a<code>scandir()<\/code> \u3092\u4f7f\u3046<\/h3>\n\n\n\n<p>\u5c0f\u898f\u6a21\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210\u3084\u4e00\u62ec\u53d6\u5f97\u306b\u5411\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>$files = scandir('.\/sample_dir');\nprint_r($files);\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">$files<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">scandir<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;.\/sample_dir&#39;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">print_r<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$files<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ \u51fa\u529b\u4f8b\nArray\n(\n    &#91;0&#93; => .\n    &#91;1&#93; => ..\n    &#91;2&#93; => file1.txt\n    &#91;3&#93; => file2.jpg\n)\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u51fa\u529b\u4f8b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">Array<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    &#91;<\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">&#93; =&gt; <\/span><span style=\"color: #D4D4D4\">.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    &#91;<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">&#93; =&gt; <\/span><span style=\"color: #D4D4D4\">..<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    &#91;<\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">&#93; =&gt; file1<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\">txt<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    &#91;<\/span><span style=\"color: #B5CEA8\">3<\/span><span style=\"color: #D4D4D4\">&#93; =&gt; file2<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\">jpg<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><code>.<\/code> \u3068 <code>..<\/code> \u3092\u542b\u3080\u70b9\u306b\u6ce8\u610f\u3057\u3001\u9664\u5916\u51e6\u7406\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>$files = array_filter(scandir('.\/sample_dir'), fn($f) => !in_array($f, &#91;'.', '..'&#93;));\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">$files<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">array_filter<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #DCDCAA\">scandir<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;.\/sample_dir&#39;<\/span><span style=\"color: #D4D4D4\">), <\/span><span style=\"color: #569CD6\">fn<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$f<\/span><span style=\"color: #D4D4D4\">) =&gt; !<\/span><span style=\"color: #DCDCAA\">in_array<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$f<\/span><span style=\"color: #D4D4D4\">, &#91;<\/span><span style=\"color: #CE9178\">&#39;.&#39;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&#39;..&#39;<\/span><span style=\"color: #D4D4D4\">&#93;));<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u3067\u53d6\u5f97\uff1a<code>glob()<\/code> \u3092\u4f7f\u3046<\/h3>\n\n\n\n<p>\u7279\u5b9a\u306e\u62e1\u5f35\u5b50\u3084\u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u306b\u6709\u52b9\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>$images = glob('.\/sample_dir\/*.jpg');\nprint_r($images);\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">$images<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">glob<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;.\/sample_dir\/*.jpg&#39;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">print_r<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$images<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ \u51fa\u529b\u4f8b\nArray\n(\n    &#91;0&#93; => .\/sample_dir\/file2.jpg\n    &#91;1&#93; => .\/sample_dir\/photo.jpg\n)\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u51fa\u529b\u4f8b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">Array<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    &#91;<\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">&#93; =&gt; <\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\">\/sample_dir\/file2<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\">jpg<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    &#91;<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">&#93; =&gt; <\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\">\/sample_dir\/photo<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\">jpg<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><code>glob()<\/code>\u306f\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u518d\u5e30\u53d6\u5f97\u306b\u306f\u975e\u5bfe\u5fdc\u3067\u3059\u304c\u3001\u5358\u7d14\u306a\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u306b\u306f\u9ad8\u901f\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u67d4\u8edf\u304b\u3064\u62e1\u5f35\u6027\u304c\u9ad8\u3044\uff1a<code>DirectoryIterator<\/code> \u3092\u4f7f\u3046<\/h3>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u5c5e\u6027\uff08\u30b5\u30a4\u30ba\u3001\u66f4\u65b0\u65e5\u6642\u306a\u3069\uff09\u3092\u542b\u3081\u3066\u7d30\u304b\u304f\u5236\u5fa1\u3057\u305f\u3044\u5834\u5408\u306b\u6709\u7528\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>$dir = new DirectoryIterator('.\/sample_dir');\nforeach ($dir as $file) {\n    if ($file->isFile()) {\n        echo $file->getFilename() . \"\\n\";\n    }\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">$dir<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #569CD6\">new<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">DirectoryIterator<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;.\/sample_dir&#39;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">foreach<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$dir<\/span><span style=\"color: #D4D4D4\"> as <\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">-&gt;<\/span><span style=\"color: #DCDCAA\">isFile<\/span><span style=\"color: #D4D4D4\">()) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">$file<\/span><span style=\"color: #D4D4D4\">-&gt;<\/span><span style=\"color: #DCDCAA\">getFilename<\/span><span style=\"color: #D4D4D4\">() <\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D7BA7D\">\\n<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ \u51fa\u529b\u4f8b\nfile1.txt\nfile2.jpg\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u51fa\u529b\u4f8b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">file1<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\">txt<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">file2<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\">jpg<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u6761\u4ef6\u5206\u5c90\u3084\u30d5\u30a1\u30a4\u30eb\u30e1\u30bf\u60c5\u5831\u306e\u53d6\u5f97\u304c\u53ef\u80fd\u306a\u305f\u3081\u3001\u5b9f\u52d9\u3067\u306e\u30d5\u30a1\u30a4\u30eb\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3084\u30ed\u30b0\u96c6\u8a08\u306b\u5411\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u3088\u304f\u3042\u308b\u30df\u30b9\u30fb\u8aa4\u89e3\u30fb\u843d\u3068\u3057\u7a74<\/h2>\n\n\n\n<p><code>scandir()<\/code>\u3084<code>glob()<\/code>\u3067\u306f\u3001<code>.<\/code>\u3084<code>..<\/code>\u3092\u542b\u3093\u3067\u3044\u305f\u308a\u3001\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u6df7\u5728\u3057\u3066\u3044\u305f\u308a\u3059\u308b\u305f\u3081\u3001\u610f\u56f3\u305b\u305a\u30eb\u30fc\u30d7\u51e6\u7406\u3067\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001<code>glob()<\/code>\u3067\u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u305d\u306e\u3082\u306e\u306f\u53d6\u5f97\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u30d5\u30a9\u30eb\u30c0\u3082\u5bfe\u8c61\u306b\u542b\u3081\u305f\u3044\u5834\u5408\u306b\u306f\u4e0d\u9069\u3067\u3059\u3002<\/p>\n\n\n\n<p><code>DirectoryIterator<\/code>\u306f\u591a\u6a5f\u80fd\u3067\u3059\u304c\u3001\u30a4\u30c6\u30ec\u30fc\u30bf\u3068\u3057\u3066\u306e\u4f7f\u3044\u65b9\u306b\u6163\u308c\u3066\u3044\u306a\u3044\u3068\u3001\u7121\u9650\u30eb\u30fc\u30d7\u3084\u5c5e\u6027\u53d6\u5f97\u30a8\u30e9\u30fc\u3092\u62db\u304f\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u53d6\u5f97\u306e\u76ee\u7684\uff08\u62e1\u5f35\u5b50\u6307\u5b9a\u30fb\u66f4\u65b0\u65e5\u30c1\u30a7\u30c3\u30af\u30fb\u518d\u5e30\u53d6\u5f97\u306a\u3069\uff09\u3092\u660e\u78ba\u306b\u3057\u305f\u3046\u3048\u3067\u3001\u9069\u5207\u306a\u65b9\u6cd5\u3092\u9078\u3076\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u307e\u3068\u3081<\/h2>\n\n\n\n<p>PHP\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u89a7\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u306b\u306f\u3001<code>scandir<\/code>\u3001<code>glob<\/code>\u3001<code>DirectoryIterator<\/code> \u306e3\u3064\u304c\u4ee3\u8868\u7684\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u308c\u305e\u308c\u306e\u9055\u3044\u3068\u5f97\u610f\u5206\u91ce\u3092\u7406\u89e3\u3057\u3001\u5bfe\u8c61\u306e\u30d5\u30a1\u30a4\u30eb\u69cb\u6210\u3084\u51e6\u7406\u8981\u4ef6\u306b\u5fdc\u3058\u3066\u9078\u629e\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u7279\u306b\u30eb\u30fc\u30d7\u51e6\u7406\u6642\u306e\u9664\u5916\u6f0f\u308c\u3084\u30d5\u30a1\u30a4\u30eb\u7a2e\u5225\u306e\u6271\u3044\u306b\u306f\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8 2. PHP\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u3068\u306f\uff1f PHP\u3067\u306f\u3001\u6307\u5b9a\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306b\u5b58\u5728\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3084\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u3084\u30af\u30e9\u30b9\u304c\u8907\u6570\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":714,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[85],"tags":[],"class_list":["post-798","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=798"}],"version-history":[{"count":2,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/798\/revisions"}],"predecessor-version":[{"id":881,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/798\/revisions\/881"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/media\/714"}],"wp:attachment":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}