View Single Post
Old 01-17-2013, 02:30 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Is this object member actually an array: $tw_user_array->ids?
Array_splice is probably not what you want. That has the purpose of extracting a part of an array, and then inserting a chunk into it. Doesn't mean it won't work, but it looks to me that you probably want to use array_slice instead which is to remove a part of an array.
PHP Code:
// assuming $tw_user_array->ids member is an array:
$users_array array_slice($tw_users_array->ids$begin$end); 
Simple as that.
This block is unnecessary:
PHP Code:
            if($i == 0) {
                
$begin 0;
                
$end 100;
            }

            else {

                
$begin $i 100;
                
$end $i 100 100;

            }; 
That entire thing can be replaced with:
PHP Code:
$begin $i 100;
$end $i 100 100
If $i is 0 as the first if dictates it could be, than begin and end would be 0 and 100 anyway.

Don't know anything about these objects you are using, but they may have a built in pagination functionality as well.

Also, if you are looping and breaking into chunks of 100 (you don't have anything here that shows this, but it is described as such), simply use array_chunk.

PHP Code:
$tw_user_array $twitteroauth->get('friends/ids');
$aSplitItems array_chunk($tw_user_array->ids100); 
That would give a multidimensional array of 100 items per outer offset. Each inner offset would represent 100 items within it. If there is no way to filter down the results of the get method and work with how you have it designed, than using array_chunk would IMO be the simplest.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote