0

Hi There,

I do have an array;

$result = array(


'Database' => $database,									                 'UserID' => $contactAmendedBy,										  'OldContactNumber'=> $_SESSION["CONTACTNUMBER"],										  'OldActivity'=> $OldActivity,										  'OldActivityValue'=> "ANT",										  'OldSource'=> $OldSource,										  'OldValidFrom'=> "25/08/2010",
[*]'OldValidTo'=> "26/08/2110",											  'Source'=> $Source,											  'ValidTo'=> $ValidTo

	
  ));

What I want to do is to give move values to dates. like;

'OldValidFrom'=> "25/08/2010","26/08/2010","27/08/2010",

'OldValidTo'=> "26/08/2110","26/08/2110","27/08/2110",

Does anybody have an idea?

Thanks!

3
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by hielo
1

You need to make sub-arrays:
'OldValidFrom'=> array("25/08/2010","26/08/2010","27/08/2010"),

'OldValidTo'=> array("26/08/2110","26/08/2110","27/08/2110"),

0

strange - it did not work in this way...

Like what? hielo's right.

Else you could place all your dates into a single string, separated by a comma and then explode them out - but I wouldn't do this.

$result = array(
'Database' => $database,									                  'UserID' => $contactAmendedBy,										    'OldContactNumber'=> $_SESSION["CONTACTNUMBER"],										  'OldActivity'=> $OldActivity,										  'OldActivityValue'=> "ANT",										  'OldSource'=> $OldSource,										  'OldValidFrom'=> array("25/08/2010","26/08/2010","27/08/2010"),
'OldValidTo'=> array("26/08/2110","26/08/2110","27/08/2110"),											  'Source'=> $Source,											  'ValidTo'=> $ValidTo
));

You can now reference OVF thus:

$from = $result['OldValidFrom'];

$firstdate = $from[0];

$num_dates_in_from = count($from);

$get_second_date_from_result = $result['OldValidFrom'][1];

Loads of stuff you can do

0

strange - it did not work in this way...

It's not clear what you mean by that, BUT if you were previously extracting the values using something like echo $result['OldValidFrom']; , now you will need to specify the index of the data that interests you- echo $result['OldValidFrom'][0]; .

You can even do a foreach($result['OldValidFrom'] as $index=>$data){ echo $data; }

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.