numerical array to object

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

numerical array to object

Post by afbase »

Would anyone know how to do this, or is there some special php function that does this?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

more details please.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

$array = array(1, 2, 3);
$obj = (object)$array;
typecasting is your friend, however as volka mentioned -- more details.
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Post by afbase »

well i have this array of URL's that i am going to CURL/regex the returned data. Trouble is when i loop through the array the website freaks out and gives me some wacky error "mdkID not found". I figure its a cookie problem or something, but if I do one link at at time, it works out just fine.

I think if i build an object from my numberical array, i should be fine. But i'm almost done with that part code!
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Post by afbase »

Jcart wrote:

Code: Select all

$array = array(1, 2, 3);
$obj = (object)$array;
typecasting is your friend, however as volka mentioned -- more details.

is there a link from php.net for that (object) thing?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

afbase wrote:is there a link from php.net for that (object) thing?
http://php.net/manual/en/language.types ... ggling.php

I would recommend you try fixing the problem at it's source instead of hacking up a bandaid solution.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

afbase wrote:I think if i build an object from my numberical array, i should be fine.
I don't see how "an object" will help you here.
Post Reply