Re: converting a multi-decisional array

[email protected] (JEFFRY KILLEN)
Newsgroups php.general
Message-ID <[email protected]>

> On Apr 29, 2021, at 1:58 PM, Don Wieland <[email protected]> wrote:
> 
> Hello,
> 
> I am in need to convert this older version of  PHP array code to a newer format because I am getting an error "Uncaught Error: Cannot use string offset as an array in, etc…” :
> 
> $avs[$row['sda_day_number']][] = 
> 	array(
> 			'dn'		=>	$row['sda_day_number'],
> 			'start'		=>	date('g:i a', strtotime($row['sda_start'])),
> 			'end'		=>	date('g:i a', strtotime($row['sda_end'])),
> 			'pstart'		=>	$pstart,
> 			'pend'		=>	$pend,
> 			'order_id' => $row['order_id']
> 		);
> 
> 
> 
> For the life of me I cannot find the proper combo of syntax for the newer version to not choke on it and the page to display properly.
> 
> Appreciate any help.
> 
> Don

Hello;

I might try: ( I have removed the empty square  brackets)

> $avs[$row['sda_day_number']] = 
> 	array(
> 			'dn'		=>	$row['sda_day_number'],
> 			'start'		=>	date('g:i a', strtotime($row['sda_start'])),
> 			'end'		=>	date('g:i a', strtotime($row['sda_end'])),
> 			'pstart'		=>	$pstart,
> 			'pend'		=>	$pend,
> 			'order_id' => $row['order_id']
> 		);

or:

> $avs[$row['sda_day_number']] = [ 
> 	                'dn'		=>	$row['sda_day_number'],
> 			'start'		=>	date('g:i a', strtotime($row['sda_start'])),
> 			'end'		=>	date('g:i a', strtotime($row['sda_end'])),
> 			'pstart'		=>	$pstart,
> 			'pend'		=>	$pend,
> 			'order_id' => $row['order_id']
> 		];

I hope this helps:
JK
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.