I am working in Youtube downloader project. Everything works fine except when I am trying to put these two portion of code in different place. I think for the usage of same variable name with different value in one script
$i = 0;
$ipbits = $ip = $itag = $sig = $size = '';
this problem occurs. I can't change the variable name because this variable name will be assigned by parse_str function in both adaptipe_array and stream_map_array with some different value. Currrently my scripts works but I think its not a good programming practice. Any suggestion for alternative to this or can it be modified in another way? Help will be appreciated.
/* create an array of available download formats */
$avail_formats[] = '';
$i = 0;
$ipbits = $ip = $itag = $sig = $size = '';
$expire = time();
foreach($adaptive_array as $format) {
parse_str($format);
$avail_formats[$i]['itag'] = $itag;
$avail_formats[$i]['size'] = $size;
$type = explode(';',$type);
$avail_formats[$i]['type'] = $type[0];
$avail_formats[$i]['url'] = urldecode($url) . '&signature=' . $sig;
parse_str(urldecode($url));
$avail_formats[$i]['expires'] = date("G:i:s T", $expire);
$avail_formats[$i]['ipbits'] = $ipbits;
$avail_formats[$i]['ip'] = $ip;
$i++;
}
/* create an array of available download formats */
$avail_formats2[] = '';
$i = 0;
$ipbits = $ip = $itag = $sig = $quality = '';
$expire = time();
foreach($stream_map_array as $format) {
parse_str($format);
$avail_formats2[$i]['itag'] = $itag;
$avail_formats2[$i]['quality'] = $quality;
$type = explode(';',$type);
$avail_formats2[$i]['type'] = $type[0];
$avail_formats2[$i]['url'] = urldecode($url) . '&signature=' . $sig;
parse_str(urldecode($url));
$avail_formats2[$i]['expires'] = date("G:i:s T", $expire);
$avail_formats2[$i]['ipbits'] = $ipbits;
$avail_formats2[$i]['ip'] = $ip;
$i++;
}