Note that there are some explanatory texts on larger screens.

plurals
  1. POconvert a string (list) into an array then output to csv in more then one row
    primarykey
    data
    text
    <p>I must arrange list of sites in order to handle updates more efficiently. </p> <p>To do so I generate a list elsewhere (which must be in the format I will present) convert it into an array to scroll through the items easily, although that is done only after I shuffle the list first so I can randomly select 30 deferent sites out of that list and write them into a .CSV column (hopefully), then rinse and repeat i.e. Iterate back to last position of the ArrayIterator and take it from there, until the list is over, my goal is to write every 30 sites into their own column on the .CSV file. </p> <p>So far I can’t get it to work. The CSV part that is the rest is fine, but on the CSV they all appear like this: </p> <pre><code>site1.com site2.com . . . site1000.com </code></pre> <p>which should be:</p> <pre><code>site1.com site31.com site62 site30.com site61.com site92.com </code></pre> <p>I searched for this for while all over… can someone please check it out perhaps throw in a few line’s to finish this script of.. I think this shouldn’t be a such big deal for some one more experienced.</p> <pre><code>&lt;?php $list = 'site1.com site2.com . . . site1000.com '; $Sites = explode("\n",$list); $Sites = preg_replace('/\s+/','',$Sites); shuffle($Sites); $Array_size = count($Sites); foreach ($Sites as $U_val){ $D++; } echo $D; echo '&lt;br&gt;&lt;hr&gt;'; $Sites = new NoRewindIterator(new ArrayIterator($Sites)); $i =0; for($R=0;$R&lt;=$D;$R++){ Run($Sites); } function Run($array){ $fp = fopen('S_list.csv', 'a+'); foreach ($array as $val){ $amount_to_run = 20; $i++; if($i&lt;=$amount_to_run){ $Write = explode("\n",$val); $Write = preg_replace('/\s+/','',$Write); fputcsv($fp, $Write); } else{ echo '&lt;br&gt;&lt;hr&gt;'; break; } close($fp); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload