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!

Recommended Answers

All 4 Replies

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"),

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

Member Avatar for diafol

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

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; }

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.