0

But i'm getting this Error Parse error: syntax error, unexpected '=', expecting ')' in I don't know how to approach this one, anyone can recommend the best practice to do this?

I can solve this type of approach using a lot of if else statement(24) but I'm thinking this much simpler?

Thanks

<?php
$streamone = 'streamone.com';
$streamtwo = 'streamtwo.com';
$streamthree = 'streamthree.com';
$streamfour = 'streamfour.com';

$streamfile = array();
if (!empty($streamone)){
    $streamfile[] = $streamone;
}
if (!empty($streamsb)){
     $streamfile[] = $streamtwo;
}
if (!empty($streamtwo)){
    $streamfile[] = $streamthree;
}

if (!empty($streamthree)){
    $streamfile[] = $streamfour;
}



$count = count($streamfile);

$streamzz = array();
for ($i = 0;  $i < $count; $i++ ){
$a=1;
$streamzz[] = array( "name" = > "Server $a" ,"select" => "iframe",  "idioma" => "",  "url" => "$streamfile[$i]");
$a++;

}

print_r($streamzz);

/*
output I want to have is

$streamzz = 
array ( "name" => "Server 1", "select" => "iframe",  "idioma" => "",  "url" => "$streamone"),
array ( "name" => "Server 2", "select" => "iframe",  "idioma" => "",  "url" => "$streamtwo"),
array ( "name" => "Server 3", "select" => "iframe",  "idioma" => "",  "url" => "$streamthree"),
array ( "name" => "Server 4", "select" => "iframe",  "idioma" => "",  "url" => "$streamfour"),


*/

1 Answers1

0

Try removing the space on this line:

$streamzz[] = array( "name" = > "Server $a" ,"select" => "iframe",  "idioma" => "",  "url" => "$streamfile[$i]");

= > should be =>.

sbgib
  • 5,580
  • 3
  • 19
  • 26