Current location: Hot Scripts Forums » Programming Languages » PHP » Find The Function


Find The Function

Reply
  #1 (permalink)  
Old 10-02-04, 01:57 PM
pavlo_s pavlo_s is offline
New Member
 
Join Date: Sep 2004
Location: Slovakia
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Find The Function

I have an array witch contains many elements.
I want to choose for example only 20 elements and display it.
Can You help me?

If I use a mysql database I provide it throw : SELECT *** LIMIT ,

Thanks!
Reply With Quote
  #2 (permalink)  
Old 10-02-04, 11:03 PM
sufyan sufyan is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Melbourne, AU
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Don't know if this is what you're looking for but try:

PHP Code:

for (i=0i<=20; ++i)

{
    echo 
$array[$i] . '<br />';

where $array is your array
__________________
suf.id.au
Reply With Quote
  #3 (permalink)  
Old 10-03-04, 01:04 AM
moronovich moronovich is offline
Junior Code Guru
 
Join Date: Oct 2004
Posts: 460
Thanks: 0
Thanked 0 Times in 0 Posts
here is the basic idea (won't work for multidimensional array)
PHP Code:

class arrayPuller {

     
/*private*/ var $elementCount;
     
/*private*/ var $arrayTemp = array();
     
/*private*/ var $message = array('Array is empty','Array element is less then pulled array');
     function 
includeArray($toIncludeArray) {
           if(!
$toIncludeArray) {
                  print 
$this->message(0);
                  exit();
           }
           
$this->arrayTemp $toIncludeArray;
           
$this->elementCount count($toIncludeArray);
     }
     function 
echoArray($start,$total) {
           
$toDisplayTotal $total $start;
           if(
$toDisplayTotal $this->elementCount) {
                 print 
$this->message(1);
                 return;
           }
           for(
$i=start$i<($i+$total); $i++) {
                  if(!
is_array($this->arrayTemp[$i])) {
                         echo 
$this->arrayTemp[$i].'<br />';
                  }
                   else {
                         echo 
'Array()';
                   }
            }
      }
}
//end of class 
just my $0.02

Last edited by moronovich; 10-03-04 at 01:16 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scrollbar!!!!!! LiLSweetie HTML/XHTML/XML 8 07-22-04 05:01 PM
PHP Error Fairnie PHP 8 06-26-04 07:15 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM
accessing existing ISP email with a PHP webmail script. nlancaster PHP 1 01-07-04 03:28 AM
Help trim code down TheLaughingBandit JavaScript 0 09-02-03 09:50 AM


All times are GMT -5. The time now is 04:34 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.