I am using the below code to split a string. And i have to repeat code for each input $ProductsURL[x] and output $productx[]
<?php
$url = "$ProductsURL[0]";
$urls = split("http://", $url);
$product0 = array();
foreach($urls as $val){
if(!$val) continue;
$product0[] = "http://$val";
}
?>
<?php
$url = "$ProductsURL[1]";
$urls = split("http://", $url);
$product1 = array();
foreach($urls as $val){
if(!$val) continue;
$product1[] = "http://$val";
}
?>
..................
Is there a way to avoid repeating the code for each input/output needed. I need the code ~100 times