Ask Your Question
4

What is the method for putting information into an array with multiple dimensions in Laravel?

asked 2023-05-06 17:31:17 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-05-06 17:58:02 +0000

huitzilopochtli gravatar image

In Laravel, you can use the array() function to create an array with multiple dimensions. Here's an example:

$myArray = array(
    array('John', 32, 'Male'),
    array('Jane', 28, 'Female'),
    array('Bob', 45, 'Male')
);

This creates an array with three rows and three columns. Each row represents a person, and each column represents a different piece of information about that person (name, age, gender).

You can also use the [] syntax to add elements to an existing array:

$myArray[] = array('Mary', 23, 'Female');

This adds a fourth row to the array with Mary's information.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-06 17:31:17 +0000

Seen: 8 times

Last updated: May 06 '23