Can PHP arrays hold items of different type

0 votes
The definition of an array in other programming languages is a container for similar-type elements. In PHP, a single array appears to be holding both strings and numbers together, despite the fact that if I declare something like int i[] it will store integers.

Will a PHP array of this type treat numbers and integers as strings?
Nov 16, 2022 in Database by Ashwini
• 5,430 points
947 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
You can store heterogeneous types inside a PHP "array," according to the PHP documentation. Scroll down to example 3.

Although the example is about keys having int or string values, it also shows that heterogeneous types can be stored because the values assigned in the example are both ints and strings.

Be aware that automatic casting occurs when using different-typed keys, which could lead to unexpected outcomes if, for example, a string contains a valid decimal representation.
answered Nov 16, 2022 by Tejashwini
• 3,820 points

edited Mar 5

Related Questions In Database

0 votes
2 answers

Different types of SQL Joins

There are 4 types of joins in ...READ MORE

answered Dec 9, 2020 in Database by bhavani
2,165 views
0 votes
1 answer

Can different databases use different name quotes?

This use of quotes is called delimited ...READ MORE

answered Sep 11, 2018 in Database by CodingByHeart77
• 3,750 points
733 views
0 votes
1 answer

Different subsets of SQL

The various subsets of SQL are as ...READ MORE

answered Sep 28, 2018 in Database by Sahiti
• 6,370 points
27,378 views
0 votes
1 answer

Different Types Of Index

There are three types of index namely: Unique ...READ MORE

answered Oct 11, 2018 in Database by DataKing99
• 8,250 points
1,600 views
0 votes
1 answer

What are the different types of index?

There are three types of index namely: Unique ...READ MORE

answered Oct 17, 2018 in Database by Sahiti
• 6,370 points
8,431 views
0 votes
1 answer

Different types of a subquery

There are two types of subquery namely, ...READ MORE

answered Oct 18, 2018 in Database by DataKing99
• 8,250 points
2,025 views
0 votes
0 answers

Automatic conversion from int to string in PHP

In PHP the variable of type integer ...READ MORE

Jun 12, 2022 in PHP by narikkadan
• 63,600 points
1,072 views
0 votes
0 answers

Converting an integer to a string in PHP

Is it possible to change an integer ...READ MORE

Aug 1, 2022 in PHP by Kithuzzz
• 38,000 points
1,028 views
0 votes
2 answers

How an object array can be converted to string array in java?

System.arraycopy is the most efficient way, but ...READ MORE

answered Aug 8, 2018 in Java by Sushmita
• 6,920 points
6,061 views
0 votes
1 answer

How to check if array is multidimensional or not?

Since the 'second dimension' could be just ...READ MORE

answered Nov 5, 2018 in Others by DataKing99
• 8,250 points
6,261 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP