thanks all for your answers, but it doesn't completely fill my
needs :s
I maube did not explain well my issue :(
In fact the question is maybe more :
I want an array of array, and being able to append the second array by
values like "key"=>"value".
I need a way to extend dynamically the second array....
if I test :
==================tested code====================
<?php
$fan_by_url = array();
$date_fans['date1']='2010-05-31 06:20:54';
$date_fans['date2']='2010-05-31 06:20:55';
$date_fans['fans']=3538;
$url='
http://www.facebook.com/21cMuseumHotels?v=wall';
$fan_by_url[$url] = array(
$date_fans['date1']=>$date_fans['fans'],
$date_fans['date2']=>$date_fans['fans'],
);
print_r($fan_by_url);
?>
==============end of tested code========================
I got :
=================tested code output =====================
[2010-05-31 06:20:54] => 3538
[2010-05-31 06:20:55] => 3538
)
)
==========end of test code output==========================
That is fine, but how can I add a value to the array ?
To get :
=================wanted code output =====================
[2010-05-31 06:20:54] => 3538
[2010-05-31 06:20:55] => 3538
date => value
date => value
date => value
date => value
date => value
............
.........
........
......
)
)
==========end of wanted code output==========================
I tried : array_push($fan_by_url[$url],$date_fans['date2']=>
$date_fans['fans']);
but it doesnt work
==========tied code ==========================
<?php
$fan_by_url = array();
$date_fans['date1']='2010-05-31 06:20:54';
$date_fans['date2']='2010-05-31 06:20:55';
$date_fans['fans']=3538;
$url='
http://www.facebook.com/21cMuseumHotels?v=wall';
$fan_by_url[$url] = array(
$date_fans['date1']=>$date_fans['fans'],
$date_fans['date2']=>$date_fans['fans'],
);
array_push($fan_by_url[$url],$date_fans['date2']=>$date_fans['fans']);
print_r($fan_by_url);
?>
==========end of trid code ==========================
result :
Parse error: parse error in line 12
:(((
any idea ?
On 10 juin, 06:04, Jasbir singh <
jsingh.vi...@gmail.com> wrote:
> Hi
>
> One more way as follows:
>
> <?php
> $fan_by_url = array();
> $date_fans['date']= array('2010-05-31 06:20:54', '2010-05-31 06:22:44');
> $date_fans['fans']=3538;
> $url='
http://www.facebook.com/21cMuseumHotels?v=wall';
>
> $fan_by_url[$url] = array(
> array($date_fans['date'][0]=>$date_fans['fans']),
> array($date_fans['date'][1]=>$date_fans['fans']),
> );
>
> foreach($fan_by_url as $key => $v)
> {
> foreach($v as $key => $va)
> {
> foreach($va as $key => $vab)
> {
> echo $key." ".$vab."<br/>";
>
> }
>
> }
>
> }
>
> ?>
>
> Thanks
>
> Jasbir Singh
> Mobile;
9717004831
>
> >
php_programmi...@googlegroups.com<
php_programming%2Bunsu...@googlegroups.com>
> > .