Announcements | Last Post | |
---|---|---|
SoC Curricula | 09/30/2017 01:08PM | |
Demarcation or scoping of examinations and assessment | 02/13/2017 07:59AM | |
School of Computing Short Learning Programmes | 11/24/2014 08:37AM | |
Unisa contact information | 07/28/2011 01:28PM |
PHP 6 - Arrays in PHP February 22, 2013 03:52PM |
Registered: 11 years ago Posts: 33 Rating: 0 |
Re: PHP 6 - Arrays in PHP February 26, 2013 08:52PM |
Registered: 11 years ago Posts: 29 Rating: 0 |
Re: PHP 6 - Arrays in PHP February 26, 2013 09:17PM |
Registered: 11 years ago Posts: 131 Rating: 0 |
Language: PHP<?php if (is_front_page()) {} elseif ( is_page( ';x-home'; ) ) { echo ';<div class="get-page">';; query_posts( array(';post_type'; => ';page';, ';numberposts'; => 2, ';post_status'; => ';publish';, ';order'; => ';ASC';, ';orderby'; => ';menu_order';, ';post__in';=> array( 412, 162, ), ) ); if (have_posts()) { while (have_posts()) { the_post(); echo ';<div class="pageboxlet"><h2><a href="';. get_permalink() .';" title="';. get_the_title() .';">';. get_the_title() .';</a></h2> <a href="';. get_permalink() .';" title="';. get_the_title() .';">';. get_the_post_thumbnail($page->ID, ';full';) .';</a><p>';; $thisContent = strip_tags($post->post_content); echo substr($thisContent, 0, 100); if(strlen($thisContent)>100){ echo ';...<a href="';. get_permalink() .';">click here</a>';; } echo ';</p></div>';; } } echo ';</div>';; } elseif ( is_page( ';x-workshop'; ) ) { echo ';<div class="get-page">';; query_posts(';posts_per_page=8&order=DESC&orderby=post_date&cat=38';); if (have_posts()) { while (have_posts()) { the_post(); echo ';<div class="post"><h3>';. get_the_title() .';</h3>';; echo ';';. the_content() .';</div>';; } } echo ';</div>';; } elseif ( is_page( ';x-competition'; ) ) { echo ';<div class="get-page">';; query_posts(';posts_per_page=8&order=DESC&orderby=post_date&cat=33';); if (have_posts()) { while (have_posts()) { the_post(); echo ';<div class="post"><h3>';. get_the_title() .';</h3>';; echo ';';. the_content() .';</div>';; } } echo ';</div>';; } elseif ( is_page( ';x-news'; ) ) { echo ';<div class="get-page">';; query_posts(';posts_per_page=8&order=DESC&orderby=post_date&cat=41';); if (have_posts()) { while (have_posts()) { the_post(); echo ';<div class="post"><h3><a href="';. get_permalink() .';" title="';. get_the_title() .';">';. get_the_title() .';</a></h3><p>';; $thisContent = strip_tags($post->post_content); echo substr($thisContent, 0, 100); if(strlen($thisContent)>100){ echo ';...<a href="';. get_permalink() .';">read more</a>';; } echo ';</p></div>';; } } echo ';</div>';; } elseif ( is_page( ';x-gallery'; ) ) { echo ';<ul class="post-gall">';; query_posts(';posts_per_page=9&order=DESC&orderby=post_date&cat=25';); if (have_posts()) { while (have_posts()) { the_post(); echo ';<li> <a href="';. get_permalink() .';" title="';. get_the_title() .';"> ';. get_the_post_thumbnail($thumbnail->ID, ';thumbnail';) .'; <h3>';. get_the_title() .';</h3></a> </li>';; } } echo ';</ul>';; } ?>
Re: PHP 6 - Arrays in PHP February 26, 2013 09:20PM |
Registered: 11 years ago Posts: 131 Rating: 0 |
Re: PHP 6 - Arrays in PHP February 28, 2013 04:02PM |
Registered: 11 years ago Posts: 33 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 01, 2013 11:41AM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 04, 2013 06:36AM |
Registered: 11 years ago Posts: 34 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 04, 2013 06:36AM |
Registered: 11 years ago Posts: 38 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 04, 2013 08:42PM |
Registered: 11 years ago Posts: 131 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 05, 2013 07:18PM |
Registered: 11 years ago Posts: 29 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 05, 2013 10:12PM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 06, 2013 02:44PM |
Registered: 11 years ago Posts: 34 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 06, 2013 04:21PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Language: PHP<form action=""> <input type="checkbox" name="vehicle" value="motorbike">I have a motor bike<br> <input type="checkbox" name="vehicle" value="Car">I have a car </form>
Re: PHP 6 - Arrays in PHP March 06, 2013 04:34PM |
Registered: 11 years ago Posts: 9 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 11, 2013 09:40PM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 12, 2013 03:00AM |
Registered: 11 years ago Posts: 38 Rating: 0 |
Language: PHPfor($key_Number = 1;$key_Number<$array_count;$key_Number++)
Language: PHPfor ($key_Number = 1; $key_Number <= $array_count; $key_Number++)
Language: PHPfor ($key_Number = 1; $key_Number < $array_count+1; $key_Number++)
variable next to eachLanguage: PHP$key_Number
, you will see what the key's value is in the for-loop. If I understand this correctly, if the key's value starts at 1, it gets to theLanguage: PHP$seasons[$key_Number]
, which is 4, when it gets to the 3rd Season. So, the value that is inLanguage: PHP$array_count
stops the execution of the for-loop before the for-loop gets to the last value in the array. If you want to start the key values at 1 in stead of 0, you have to add 1 to the value ofLanguage: PHP$array_count
. For example, if you want to start with a key of 11, you have to add 11 to the value of $array_count, like so:Language: PHP$array_count
Language: PHP$seasons = array(11=>"Autumn", 12=>"Winter", 13=>"Spring", 14=>"Summer"); $array_count = count($seasons); for ($key_Number = 11; $key_Number < $array_count+11; $key_Number++) { print $key_Number. " " .$seasons[$key_Number]; } ?>
Re: PHP 6 - Arrays in PHP March 12, 2013 08:39AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: PHP 6 - Arrays in PHP March 14, 2013 12:54AM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 14, 2013 12:59PM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 16, 2013 08:21AM |
Registered: 11 years ago Posts: 16 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 18, 2013 09:49AM |
Registered: 11 years ago Posts: 51 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 18, 2013 01:09PM |
Registered: 11 years ago Posts: 131 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 18, 2013 08:47PM |
Registered: 11 years ago Posts: 51 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 18, 2013 09:00PM |
Registered: 11 years ago Posts: 29 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 19, 2013 02:07PM |
Registered: 12 years ago Posts: 106 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 20, 2013 10:32AM |
Registered: 11 years ago Posts: 15 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 20, 2013 11:30PM |
Registered: 11 years ago Posts: 18 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 20, 2013 11:52PM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 21, 2013 05:20PM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 22, 2013 11:07PM |
Registered: 12 years ago Posts: 106 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 26, 2013 08:35PM |
Registered: 11 years ago Posts: 64 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 26, 2013 10:37PM |
Registered: 11 years ago Posts: 131 Rating: 0 |
Re: PHP 6 - Arrays in PHP March 27, 2013 08:01AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: PHP 6 - Arrays in PHP March 31, 2013 01:09PM |
Registered: 17 years ago Posts: 60 Rating: 0 |