Reply to Re: stdClass Object - get_object_vars

Your name:

Reply:


Posted by juglesh on 09/06/05 21:17

Janwillem Borleffs wrote:
> juglesh wrote:
> > hello, i have a d/l'd class that gives an array which prints like
> > this:
> >
> > stdClass Object
> > (
> >
>
> This is not an array, but an object
>
> > i cannot seem to access the values using
> > $thearray['first name']['inputtype']
> >
>
> This works for arrays For objects, you should do this as follows:
>
> $theobject->{'first name'}->inputtype;
>
> Note that I used curly braces here because 'first name' contains a space
> character.
>
> If this wasn't the case, you could do it like this:
>
> $theobject->firstname->inputtype;
>
> > Here is the class, oh, and maybe someone can see why it's putting two
> > end brackets on the [first name]], etc.
> >
> [...]
> > // section
> > if ((substr($data, 0, 1) == '[') AND (substr($data, -1) == ']')) {
> > $this->_last_section = substr($data, 1, (strlen($data) - 1));
> > return;
> > }
> >
>
> $this->_last_section = substr($data, 1, - 1);

both suggestions work fine, thank you very much. in fact, the first
fix didnt work till I did the second.
>
> BTW, you should also take a look at the parse_ini_file function:
>
> http://www.php.net/manual/en/function.parse-ini-file.php

i am aware of this, thanks. The main reason i liked the class above
was:
// check for comma's and spaces in value, if so make array of it
if (strpos($value, ", ")) {
$list = explode (",", $value);
though, really, I could just send the results of parse-ini-file through
that. Also, for this thing i'm doing, I might need even more
dimensions with named keys, so, I guess I'll need to modify the code to
look for [key] within the values, etc.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация