Re: [PHP] Array question
I'd also like to add to that: $array = array(); $array[] = 'text'; $array[2] = 123; $array[] = 'hello'; Would output: $array( 0 => 'text', 2 => 123, 3 => 'hello', ); Note the missing index 1, as php makes a numerical index that is one greater than the highest already in use. As the index 2 was explicitly created, php made the next one at 3. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "chris h" Date: Sat, Sep 25, 2010 22:05 Subject: [PHP] Array question To: "MikeB" Cc: Mike, $results[] will automatically push a value unto the end of an array. So doing this... -- $magic = array(); $magic[] = 'a'; $magic[] = 'b'; $magic[] = 'c'; - is exactly this same as doing this... -- $normal = array(); $normal[0] = 'a'; $normal[1] = 'b'; $normal[2] = 'c'; - And yes, in your example "$results[]" would be equivalent to "$results[$j]" For more reference: http://www.php.net/manual/en/language.types.array.php Chris H. On Sat, Sep 25, 2010 at 4:31 PM, MikeB wrote: > I have the following code: > > $query = "SELECT * FROM classics"; > $result = mysql_query($query); > > if (!$result) die ("Database access failed: " . mysql_error()); > $rows = mysql_num_rows($result); > > for ($j = 0 ; $j < $rows ; ++$j) > { >$results[] = mysql_fetch_array($result); > } > > mysql_close($db_server); > > My question, in the loop, why does tha author use: > > $results[] = mysql_fetch_array($result); > > instead of (as I would expect): > > $results[$j] = mysql_fetch_array($result);? > > What PHP magic is at work here? > > Thanks. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
[PHP] SEO Experts?
Hello, Do we have any SEO experts on this list? I'm not one, learning only, reading a book and a few articles/tutorials from webmasters, and I'm wanting to optimize an existing site to get the best search rank possible. Some techniques, dos and don'ts would be appreciated. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SEO Experts?
At 8:09 AM -0400 9/26/10, David Mehler wrote: Hello, Do we have any SEO experts on this list? I'm not one, learning only, reading a book and a few articles/tutorials from webmasters, and I'm wanting to optimize an existing site to get the best search rank possible. Some techniques, dos and don'ts would be appreciated. Thanks. Dave. Dave: That's far too broad a question. SEO can't be broken down into a few do's and don'ts that can be listed on a post. That's like asking "Anyone have any do's and don'ts about PHP?" Please be reasonable with your questions. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array question
At 3:31 PM -0500 9/25/10, MikeB wrote: -snip- My question, in the loop, why does tha author use: $results[] = mysql_fetch_array($result); instead of (as I would expect): $results[$j] = mysql_fetch_array($result);? What PHP magic is at work here? Mike: That's just a shorthand way to populate an array in PHP. One of the reasons for this feature is that somewhere in your code you may not know what the next index should be. So, if you use -- $results[] = $next_item; -- then the $next_item will be "automagically" added to the next available index in the array. So you may be right in calling it "PHP magic" because I have not seen this in other languages. Understand? Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SEO Experts?
Dave, the general advice I can give you is focus on fundamentals not on fads. domain name, h1, h2, title tags and alt attributes are key tools to tell bots what your pages are about. view your pages without javascript or css to see how a bot will view them. links from other sites are important as well, but don't forget internal links. if you have links pointing from several pages on your site to one important page, search engines can tell that. unique content is also great as it distinguishes your site from competitors. -nathan On Sep 26, 2010 6:10 AM, "David Mehler" wrote: > Hello, > Do we have any SEO experts on this list? I'm not one, learning only, > reading a book and a few articles/tutorials from webmasters, and I'm > wanting to optimize an existing site to get the best search rank > possible. Some techniques, dos and don'ts would be appreciated. > Thanks. > Dave. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >
[PHP] Re: SEO Experts?
On 9/26/2010 8:09 AM, David Mehler wrote: Hello, Do we have any SEO experts on this list? I'm not one, learning only, reading a book and a few articles/tutorials from webmasters, and I'm wanting to optimize an existing site to get the best search rank possible. Some techniques, dos and don'ts would be appreciated. Thanks. Dave. Google "Webmasters" is a very good resource. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SEO Experts?
Avoid 302's as mush as possible. --Shreyas On Sun, Sep 26, 2010 at 8:55 PM, Al wrote: > > > On 9/26/2010 8:09 AM, David Mehler wrote: > >> Hello, >> Do we have any SEO experts on this list? I'm not one, learning only, >> reading a book and a few articles/tutorials from webmasters, and I'm >> wanting to optimize an existing site to get the best search rank >> possible. Some techniques, dos and don'ts would be appreciated. >> Thanks. >> Dave. >> > > > Google "Webmasters" is a very good resource. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Regards, Shreyas Agasthya