使用explode将内容添加到现有数组

I have this statement inside a loop.

$chosenUrls = explode ( ',' , $connect[$i]['url'] );

Is there anyway to get it to add to the $chosenUrls array, rather than replacing what's in there?

You can have $chosenUrls[] = explode ( ',' , $connect[$i]['url'] ) to add new url in your array in every iteration.

Try:

$chosenUrls=array();

 for(...)
{
  array_push($chosenUrls,explode ( ',' , $connect[$i]['url'] ));
}

Your current code tells it to replace $chosenUrls every time. You need to modify it:

for(...){

 $chosenUrls[] = explode ( ',' , $connect[$i]['url'] );

}

Note the [] after $chosenUrls. This will push a new element into $chosenUrls on each iteration.