numerical array to object
Moderator: General Moderators
numerical array to object
Would anyone know how to do this, or is there some special php function that does this?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
$array = array(1, 2, 3);
$obj = (object)$array;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!
I think if i build an object from my numberical array, i should be fine. But i'm almost done with that part code!
Jcart wrote:typecasting is your friend, however as volka mentioned -- more details.Code: Select all
$array = array(1, 2, 3); $obj = (object)$array;
is there a link from php.net for that (object) thing?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
http://php.net/manual/en/language.types ... ggling.phpafbase wrote:is there a link from php.net for that (object) thing?
I would recommend you try fixing the problem at it's source instead of hacking up a bandaid solution.