Jump to content
IvanGS

concatenar Array's....

Recommended Posts

IvanGS

boas, alguém me pode dizer como concateno array's que estejam dentro de um foreach?

Share this post


Link to post
Share on other sites
IvanGS

foreach ($mounth as $mes)
{

$mes = $_COOKIE['login']."_".$ano01."_".$mes;

$sql = mysql_query("SELECT * from $mes WHERE col_02='$conta'");
while($row = mysql_fetch_array($sql))
{
	$col01 = $row['col_01'];
	$row01 = str_replace(',', '.', $row['col_03']);
	$row01 = (int) ((float) $row01);
	$row02 = str_replace(',', '.', $row['col_04']);
	$row02 = (int) ((float) $row02);
}
	$finalvalue = $row01 - $row02;
}




foreach ($mounth_01 as $mes01)
{

$mes01 = $_COOKIE['login']."_".$ano02."_".$mes01;

$sql_02 = mysql_query("SELECT * from $mes01 WHERE col_02='$conta_02'");
while($row_02 = mysql_fetch_array($sql_02))
{
	$col01_02 = $row_02['col_01'];
	$row01_02 = str_replace(',', '.', $row_02['col_03']);
	$row01_02 = (int) ((float) $row01_02);
	$row02_02 = str_replace(',', '.', $row_02['col_04']);
	$row02_02 = (int) ((float) $row02_02);
}
	$finalvalue2 = $row01_02 - $row02_02;
}

os $finalvalue e o $finalvalue2 são variáveis que estão dentro de vários if's que são apenas decisões para os cálculos.

o que eu preciso é que eu consigo meter  esta variável $finalvalue vá recebendo valores (tipo: 1451, 354215, etc)  e com a $finalvalue2 seja a mesma coisa.

Share this post


Link to post
Share on other sites
mAiN_iNfEcTiOn

Olá IvanGS,

Verifica se a função array_merge() faz aquilo que pretendes:


for($i=1;$i<13;$i++)
    $mounth = array_merge($mounth , ${"mounth".$i} );

print_r($mounth);

Share this post


Link to post
Share on other sites
IvanGS

muito obrigado pelas respostas, mas resolvi de uma maneira que devo ter testado umas 100X. para quem precisar:


$array3[] = $finalvalue;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.