Betty_S Posted January 13, 2007 Share Posted January 13, 2007 Hi,I know the both of the above are kinds of arrays which have been retrieved from the database. Why is there 2 different ways to approach it and what's better?Thanks. Quote Link to comment Share on other sites More sharing options...
.josh Posted January 13, 2007 Share Posted January 13, 2007 Please make an attempt to post in the right forum. The forum that says "Things about the site and board" is not the right place. The forum that says "PHP Help," although I know it really is counter-intuitive, [i]is[/i] the right place. $x->y is an object called $x and y is either a property or method. $x['y'] is an array called $x and y is the name of one of its array elements. The array element would physically be called 'y'. Neither are database specific. There are different methods to retrieve data from a database, which involve different ways of holding that data. Quote Link to comment Share on other sites More sharing options...
taith Posted January 13, 2007 Share Posted January 13, 2007 $x->$y is for classes$x[$y] is an array, much more commonly used for databases(mysql_fetch_array()) Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 13, 2007 Share Posted January 13, 2007 Perhaps the OP was referencing this way of creating an array as well:$x = array ('y' => "data");vs.$x['y'] = "data";There's no difference that I'm aware of. Quote Link to comment Share on other sites More sharing options...
.josh Posted January 13, 2007 Share Posted January 13, 2007 or perhaps the OP was looking at a script that involved using classes for database handling. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.