Plz tel me any wrong with this code urgently

$languages =array(“te”,“hi”);
$startMovieIds = array(8291800001, 9543200001);
$lastMovieIds = array( 8291800100, 9543210000);
$startCelebIds = array( 8912100001, 2345100001);
$lastCelebIds = array(8912112540, 2345110000);

for($langIndex = 0; $langIndex<=count($languages);$langIndex++)
{

for($i=$startMovieIds;$i<=$lastMovieIds;$i++)
{

	array_push($urls,'http://www.nthwall.com/'.$languages[$langIndex].'/'.$i);

}
for($j=$startCelebIds;$j<=$lastCelebIds;$j++)
{
array_push($urls,‘http://www.nthwall.com/‘.$languages[$langIndex].’/’.$j);
}
}
is there any error …iam trying to push values into array(urls)…but it showing array to string conversion array…

one more thing urls is an array
$urls=array();

plz let me tel any wrong with this code
thnks

Anything wrong? Why, is it giving you an error?

it showing error like allowed memory exhausted but i included <?php ini_set(“memory_limit”,“24M”);?> to allow the memory …but it still showing error allowed memory exhausted…everytime i increased memory every time when it showing error like allowed memory exhausted…but it still showing error…

One thing is you can’t use arrays like this:


for($i=[B]$startMovieIds[/B];$i<=[B]$lastMovieIds[/B];$i++)

If you want to use the number of elements in the array, and you don’t want to loop through the array using foreach, use count($lastMovieIds)

if u dont mind plz write one for loop for that …iam new to php.

Could you explain in words what you are trying to do? And give the end result you would like to have using the data from your first post?

what iam trying to doing here is …iam trying to insert the each and every url into arry(urls) and this for the purpose of sitemap…
i have a array like

$urls=array{‘http://www.xxx.com’,
http://www.nthwall.com/te,’}

and iam running two for loops for inserting that data into urls array…
after running of each for loop that url is inserting into urls array

for($langIndex = 0; $langIndex<=count($languages);$langIndex++)
{

for($i=$startMovieIds;$i<=$lastMovieIds;$i++)
{

array_push($urls,‘http://www.nthwall.com/‘.$languages[$langIndex].’/’.$i);

}
for($j=$startCelebIds;$j<=$lastCelebIds;$j++)
{
array_push($urls,‘http://www.nthwall.com/‘.$languages[$langIndex].’/’.$j);
}
}

it showing error at array_push…
thnks

Why do you have two startmovie ids? You want to loop from the first start id to the first last id, and from the second start id to the second last id?
Does every start id always have a corresponding last id ?

$languages =array(“te”,“hi”);
$startMovieIds = array(8291800001, 9543200001);
$lastMovieIds = array( 8291800100, 9543210000);
$startCelebIds = array( 8912100001, 2345100001);
$lastCelebIds = array(8912112540, 2345110000);
in this i have two languages (te,hi)
8291800001 is te language startId and 8291800100 is te language lastId likewise 8912100001 is first celebId of te language 8912112540 is last celeb id of te language
and in same way for hi language

and in this each language has corresponding Id’s …id’s are different for each language

Ok, now assuming that all arrays are like you posted, it should be something like this:


$languages =array("te","hi");
$startMovieIds = array(8291800001, 9543200001);
$lastMovieIds = array( 8291800100, 9543210000);
$startCelebIds = array( 8912100001, 2345100001);
$lastCelebIds = array(8912112540, 2345110000);

// loop through the language array with foreach
foreach ($languages as $langIndex => $language) {

  // loop from start movie id to last movie id for the current language
  for ($i=$startMovieIds[$langIndex];$i<=$lastMovieIds[$langIndex];$i++) {
    $urls[] = 'http://www.nthwall.com/'.$language.'/'.$i;
  }

  // loop from stard celeb id to last celeb id for the current language
  for ($j=$startCelebIds[$langIndex];$j<=$lastCelebIds[$langIndex];$j++) {
    $urls[] = 'http://www.nthwall.com/'.$language.'/'.$j;
  }
}

As you can see, I used $urls instead of array_push, because the manual says:

If you use array_push() to add one element to the array it’s better to use $array = because in that way there is no overhead of calling a function.

thnks guido2004 its working