{"id":13073,"date":"2022-12-20T00:59:09","date_gmt":"2022-12-19T22:59:09","guid":{"rendered":"https:\/\/www.beseit.net\/?p=13073"},"modified":"2022-12-20T12:52:20","modified_gmt":"2022-12-20T10:52:20","slug":"13073","status":"publish","type":"post","link":"http:\/\/www.beseit.net\/?p=13073","title":{"rendered":"Script. Selecciona un primer caracter predefinit de un array (en aquest cas &#8216;C,c&#8217;) i crea un fitxer."},"content":{"rendered":"<p>Per alguna circunst\u00e0ncia en lloc del caracter TAP (09) les l\u00ednies &#8216;pentinades&#8217; somplen de C2 A0. Aix\u00f2 causar\u00e0 errors si fem un copy\/pega del codi al editor SUBLIME 3. Per aix\u00f2 s&#8217;hauran de suprimir esl jocs &#8216;C2 A0&#8217;.<br \/>\n<a href=\"https:\/\/www.beseit.net\/wp-content\/uploads\/2022\/12\/REPLACE.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13078\" src=\"https:\/\/www.beseit.net\/wp-content\/uploads\/2022\/12\/REPLACE.png\" alt=\"\" width=\"401\" height=\"56\" srcset=\"http:\/\/www.beseit.net\/wp-content\/uploads\/2022\/12\/REPLACE.png 401w, http:\/\/www.beseit.net\/wp-content\/uploads\/2022\/12\/REPLACE-300x42.png 300w\" sizes=\"auto, (max-width: 401px) 100vw, 401px\" \/><\/a><\/p>\n<p>[php]<\/p>\n<p>&lt;?php<br \/>\n$catala     = &quot;&quot;;<br \/>\n$new_line   = 0;<br \/>\n$dic        = file(&#8216;C-definicions_mots0.txt&#8217;); \/\/array de 6145<br \/>\n$num_linies = count($dic); \/\/hauria de ser 6145<br \/>\necho &quot;$num_linies &lt;br&gt;&quot;;<br \/>\n$myfile = fopen(&quot;A-LLISTA.txt&quot;, &quot;w&quot;) or die(&quot;Unable to open file!&quot;); \/\/a-&gt; mode append, w-&gt;esborra<br \/>\n$i      = 0;<br \/>\nwhile ($i &lt; $num_linies) {<br \/>\n    $first_char = mb_substr($dic[$i], 0, 1, &#8216;UTF8&#8217;); \/\/agafo el primer caracter de la la linia dic[$i]<br \/>\n    switch ($first_char) {<br \/>\n        case C:<br \/>\n        case c:<br \/>\n            if ($catala != &quot;&quot;) {<br \/>\n                $catala = str_replace(&quot;\\x0d\\x0a&quot;, &quot;&quot;, $catala);<br \/>\n                $txt    = &quot;$catala \\n&quot;;<br \/>\n                fwrite($myfile, $txt);<br \/>\n                $txt    = &quot;&quot;;<br \/>\n                $catala = $dic[$i]; \/\/nova linia<br \/>\n                echo &quot;$dic[$i] &#8211;catala= $catala &lt;br&gt;&quot;;<br \/>\n            }<br \/>\n            $catala = $dic[$i];<br \/>\n            echo &quot;$i&#8211;$first_char&#8211;0k $catala &lt;br&gt;&quot;;<br \/>\n            $dic[$i] = str_replace(&quot;\\x0d\\x0a&quot;, &quot;&quot;, $dic[$i]);<br \/>\n            break;<br \/>\n        default:<br \/>\n            $catala = $catala . $dic[$i];<br \/>\n            echo &quot;muttttttttttttt$i&#8211;$first_char $catala&lt;br&gt;&quot;;<br \/>\n            break;<br \/>\n    }<br \/>\n    $i++;<br \/>\n} \/\/fi del while<\/p>\n<p>[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Per alguna circunst\u00e0ncia en lloc del caracter TAP (09) les l\u00ednies &#8216;pentinades&#8217; somplen de C2 A0. Aix\u00f2 causar\u00e0 errors si fem un copy\/pega del codi al editor SUBLIME 3. Per aix\u00f2 s&#8217;hauran de suprimir esl jocs &#8216;C2 A0&#8217;. [php] &lt;?php &hellip; <a href=\"http:\/\/www.beseit.net\/?p=13073\">Continua llegint <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[],"class_list":["post-13073","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts\/13073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13073"}],"version-history":[{"count":9,"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts\/13073\/revisions"}],"predecessor-version":[{"id":13083,"href":"http:\/\/www.beseit.net\/index.php?rest_route=\/wp\/v2\/posts\/13073\/revisions\/13083"}],"wp:attachment":[{"href":"http:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13073"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.beseit.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}