473,491 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Short syntax for array in PHP

Hello,

is there a shorter syntax for array beside array("one", "two"),
something link {"one", "two"}?

cheers

sebastian
Jul 11 '07 #1
3 2404
On Jul 11, 9:46 am, Sebastian Deutsch <spam...@9elements.comwrote:
Hello,

is there a shorter syntax for array beside array("one", "two"),
something link {"one", "two"}?

cheers

sebastian
Not that I know of.

What's wrong with the array("one", "two") syntax? Your proposed { }
syntax is only shorted by the word "array" -- and the more items you
have in the array the less significant it becomes.

Jul 11 '07 #2
On Jul 11, 9:46 am, Sebastian Deutsch <spam...@9elements.comwrote:
Hello,

is there a shorter syntax for array beside array("one", "two"),
something link {"one", "two"}?

cheers

sebastian
Actually, now that I thought about it more, you could write a function
and shorten it to a single character. So something like this:

function a() {
$arr = func_get_args();
return $arr;
}

$anArray = a('one', 'two');

Of course you can't assign keys that way, though.

Jul 11 '07 #3
"Sebastian Deutsch" <sp*****@9elements.comwrote in message
news:f7**********@news01.versatel.de...
>
is there a shorter syntax for array beside array("one", "two"),
something link {"one", "two"}?
The only other syntax I'm aware of that may save you some typing is the
automatic assignment of subscripts, i.e.

$a[] = "I'm"; //$a[0] = "I'm"
$a[] = "the"; //$a[1] = "the"

Etc.

But as far as the "array" keyword ... no meaningful shortcut I'm aware of.

--
David T. Ashley (dt*@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)
Jul 11 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2761
by: Danny Anderson | last post by:
Hola! I have an array of shorts that represents a stream of data. This data is packed in tight, so certain elements may actually contain data for more than one variable. I am to decipher this...
7
1778
by: Philipp | last post by:
Hello I'm working on a piece of code which I did not write and it has variables defined as: unsigned short i:13; unsigned short j:13; unsigned short k:3; As I understand the code, this...
99
8963
by: Glen Herrmannsfeldt | last post by:
I was compiling a program written by someone else about six years ago, and widely distributed at the time. It also includes makefiles for many different systems, so I know it has been compiled...
0
1118
by: db | last post by:
I am new to vb. net, and would like to implement a method I used in vb6. I need to write binary data to the hard drive ASAP. I am writting ~ 5Mbytes of data (synchrously)every 5 seonds for...
2
4634
by: Ole | last post by:
Hi, Is there a better / faster way to convert a byte array to a short array than to use Convert.toInt16(bytearray, i) in a loop? Thanks Ole
9
16764
by: Alberto Cardoso | last post by:
Is there a direct way to convert a short array to a byte array? I dont to use a for and cast every short to a byte. I want something like the BitConverter class that accpets a short array as...
2
2478
by: JJA | last post by:
I'm looking at some code I do not understand: var icons = new Array(); icons = new GIcon(); icons.image = "somefilename.png"; I read this as an array of icons is being built. An element of...
1
20048
by: jackmejia | last post by:
Hello, I been working on an application that need to build a data package to send it over the network, I have an unsigned short as the data length, this is two bytes. On the server side I am...
17
3449
by: spasmous | last post by:
I need a way to search through a block of memory for a char array "DA" using a pointer to a short. Ideally I would like to write something like: short *data = ... some data...; int j = 0;...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.