Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating array from an array with value manipulation
    text
    copied!<p>I have a text area where coworkers input file names with no extensions, followed by a return. my code takes this input list and creates an array called <code>$list</code>. it will then take that array and create an updated array called <code>$genList</code> with extra file names like this:</p> <pre><code>$fileString = $_POST['fileList']; $unique = $_POST['unique']; $size = $_POST['size']; $generateArray = $_POST['generateArray']; $list = explode("\r\n",$fileString); if ($generateArray == "yes") { if ($size == "5x7inimpos") { $genList = array(); foreach($list as $element) { array_push($genList, $element . "_f", $element . "_b", $element . "_i"); } } $list = array(); $list = $genList; } </code></pre> <p>so as it stands, if a worker inputs some file names like so:</p> <pre><code>HOL_12_001_00 HOL_12_002_00 HOL_12_003_00 </code></pre> <p>it will eventually get converted as an array with the extensions on the end of the file name like this:</p> <pre><code>$list = array(HOL_12_001_00_f, HOL_12_001_00_b, HOL_12_001_00_i, HOL_12_002_00_f, HOL_12_002_00_b, HOL_12_002_00_i, HOL_12_003_00_f, HOL_12_003_00_b, HOL_12_003_00_i); </code></pre> <p>but what i really need to do is have the final array (with the <code>_f</code>, <code>_b</code>, <code>_i</code>) inside of the file name like this:</p> <pre><code>$list = array(HOL_12_f_001_00, HOL_12_b_001_00, HOL_12_i_001_00, HOL_12_f_002_00, HOL_12_b_002_00, HOL_12_i_002_00, HOL_12_f_003_00, HOL_12_b_003_00, HOL_12_i_003_00); </code></pre> <p>how can i achieve this?</p>
 

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