0

I have a form that users can enter multiple Task IDs in a box then click submit to search for these. I'm creating an array of these like this:

$taskIDsInput = $_GET['taskID'];
$taskIDsArray = explode( "\r", $taskIDsInput);

which creates an array that looks like this:

Array 
(
[0] => 60092296
[1] => 60092323
)

For each of these IDs I need to construct a line like the following:

$findTasksRequest['query'][0]['TaskNumber'] = '=='.$taskIDsInput;

I need to increase the [0] by one for each taskID (it will be used to create json so needs to start at 0) and also replace the $taskIDsInput with the value for each taskID contained in the array. I've tried many variations here but can't work out the correct PHP syntax here and whether I should be using a foreach loop or something else.

My latest attempt looks like this:

    for($i = 0; $i < count($taskIDsArray); $i++) { 
    ${'findTasksRequest[\'query\']' . ($i+1)}['TaskNumber'] = '=='.$taskIDsArray[$i];
}

which isn't working correctly.

user982124
  • 4,416
  • 16
  • 65
  • 140

0 Answers0