Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 12-06-2003, 07:25 PM   #1 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
array pointer?

how do i change the internal pointer to a specific value in an array?

ugh.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 12-07-2003, 04:15 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
=/ dunno .. tried to find it.. what do you use internal pointers for?
__________________
Mike
sde is offline   Reply With Quote
Old 12-07-2003, 05:39 PM   #3 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
here is what i did..

first find the position you want, then advance to that position.

PHP Code:
  $position=array_search($pic,$imageArray);
  for (
$i=0$i $position$i++)
  {
    
next($imageArray);
  } 
i am using for an image gallery on a new site i am working on

the array pointer is the value that the array is currently sitting at (that is my understanding of it).

please excuse the UGLY urls, i am still in early development: http://sevensixtyone.com/photos.php?...7_dragonlounge
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 12-07-2003, 07:30 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
seems like your kind of limited with pointers..

why not use something like this:
PHP Code:
<?
for ($i=0$i count($array); $i++)
{
  
$imageArray[$i];
}
?>
then $i is always your current position.. i'm not sure i understand fully what you're using the pointer for though.
__________________
Mike
sde is offline   Reply With Quote
Old 12-07-2003, 10:24 PM   #5 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
you should not be using the internal array pointer for this. that is not what it is designed for, and some operations may modify it unexpectedly.

use indexes, like sde suggested.

PHP Code:
<?
$position 
array_search($pic,$imageArray);

// get the next pic
$position++;
$next_pic $imageArray[$position];
?>
if your arrays are hashed (key-based), use the each() function or similar.
joe_bruin is offline   Reply With Quote
Old 12-08-2003, 10:17 AM   #6 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
i want to use the next() and prev() functions to determine what the next value and the previous value in the array are. if they dont exist then they return false, making it very easy to generate links.

how will the pointer get messed up if the only thing i am using the array for is this?
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 12-08-2003, 11:25 AM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
PHP Code:
<?
// if next()
if($array[$i+1])
  echo 
"true";

// if previous()
if($array[$i-1])
  echo 
"true";
?>
__________________
Mike
sde is offline   Reply With Quote
Old 12-08-2003, 12:27 PM   #8 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
check your email mike.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 12-08-2003, 04:51 PM   #9 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
updated code, works just like before.
thanks for the info guys.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Reply

Bookmarks

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
working with Array Goong MS Technologies ( ASP, VB, C#, .NET ) 3 07-22-2004 01:14 PM
breaking down an array from a form metazai PHP 12 07-09-2004 07:18 AM
array of characters in a structure TheDreamless Standard C, C++ 3 04-18-2003 05:30 PM
pointer to function with class? Kportertx Standard C, C++ 5 04-11-2003 06:12 AM
adding to an array in php sde PHP 1 06-12-2002 12:04 PM


All times are GMT -8. The time now is 10:59 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting