Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

php array like a struct

Hi

I need to create an equivalent to a struct in php

my array looks like this:

$employee = array(
		'name' 	=> "",
		'id' 	=> 0,
		'projects' => 0,
		'ontime' => 0,
		'ahead' => 0,
		'overdue' => 0
	);
	

Open in new window



how can I make an array of employee?
0
cycledude
Asked:
cycledude
  • 4
2 Solutions
 
Randy PooleCommented:
$employees=array();
$employees.push($employee);

Open in new window

But you would probably want to create an employee class instead
0
 
cycledudeAuthor Commented:
hi, thanks..

how would it work with a class?
0
 
cycledudeAuthor Commented:
Hi

I get this when I try it

Fatal error: Call to undefined function push()

I am running on a wamp server on local machine, do i need to load a specific module?
0
 
cycledudeAuthor Commented:
array_push($employees,$employee) worked a treat ;o)
0
 
cycledudeAuthor Commented:
thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now