Jump to content

[SOLVED] Create Object Properties Dynamicly


jjacquay712

Recommended Posts

I was looking at some JavaScript and was wondering if there was an equivalent in PHP. Basically you can create and access object properties dynamically by using something called Square Bracket Syntax. It looks like this:

 

document.body

Or you could do this:

document['body']

 

By using Square Bracket Syntax, you could create object properties dynamically using a loop like this:

 

for (var n = 0; n < 10; n++) {
      document[n] = "whatever";
}

 

Is there anyway to do this in PHP, without using an associative array?

 

 

              Thanks, John.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.