Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue splitting an array for use in another array
    primarykey
    data
    text
    <p>I have some data, which i currently have hard coded, basically i am trying to split the numbers, 1-port and recreate it as</p> <pre><code>'INSERT INTO '.$tbl_name.'(PortNumber) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(145),(146),(147),(148),(149),(150),(151),(152),(153),(154),(155),(156)'; </code></pre> <p>and etc.. i have a pretty good start i think..</p> <p>PHP</p> <pre><code>//post vars $port = 24; //(int)$_POST['ports']; $super = 2; //(int)$_POST['super']; $col = 12; //(int)$_POST['columns']; $row = 2; //(int)$_POST['rows']; //rest of vars $halfPort=$port/2;//12 $colHalf = $col / $super;//6 $half=$colHalf-1;//5 $count=1; $and=1; $one=1; echo "&lt;h1&gt;here goes nothen&lt;/h1&gt;&lt;br&gt;&lt;br&gt;"; //sperate port $finalArray = array(); for ($i = $port; $i &gt;= 1; $i -= $colHalf) { $tempArray = array(); for ($j = 0; $j &lt; $colHalf; $j++) { $tempArray[] = $i - $j; } $tempArray[]= sort($tempArray); $finalArray[] = implode(",", $tempArray); } $finalArray = array_reverse($finalArray); echo "&lt;pre&gt;" . print_r($finalArray, true) . "&lt;/pre&gt;"; echo "&lt;br&gt;&lt;br&gt;"; //sql for insert $sqlinsert=' INSERT INTO '.$tbl_name2.' (PortNumber) VALUES '; $start='('; $end=')'; //preset b $b=0; for($c = $port; $c &gt;= 1; $c -= $colHalf) { $queryStart = array(); $queryStart[]=explode(',',$finalArray[$b]); echo "&lt;pre&gt;" ."start". print_r($queryStart, true) . "&lt;/pre&gt;"; for($s=0; $s&lt;6; $s+=$and) { $queryEnd = array(); $queryEnd[] = $start.$queryStart[$s].$end; echo "&lt;pre&gt;" ."end". print_r($queryEnd, true) . "&lt;/pre&gt;"; } $b+=1; } </code></pre> <p>to view it live insert it here: <a href="http://phptester.net/index.php?lang=en" rel="nofollow">http://phptester.net/index.php?lang=en</a> baisaclly it gets to <code>$queryEnd</code>, everything goes down hill, any ideas?</p>
    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