I want to get the first record and last record in an array. I don't
want any other records, but am not finding how to do it. What I am
doing is pulling out information from a database, where the sql query
would have a result much like this:
10
11
12
13
14
15
16
And I want to grab the first and last items in the array, so in this
case, 10 and 16.
Any advice would be appreciated. 3 45283
On Fri, 16 Nov 2007 00:15:52 +0100, mtuller <mi******@gmail .comwrote:
I want to get the first record and last record in an array. I don't
want any other records, but am not finding how to do it. What I am
doing is pulling out information from a database, where the sql query
would have a result much like this:
10
11
12
13
14
15
16
And I want to grab the first and last items in the array, so in this
case, 10 and 16.
RTFM.....
$first = reset($array);
$last = end($array);
For ranges, look at array_slice()/array_splice()/count()
--
Rik Wasmus
Yes - how dare a user ask for php help on a php newsgroup .
<comp.lang.ph p>
<Rik Wasmus>
<Fri, 16 Nov 2007 00:19:06 +0100>
<op************ ***@metallium.l an>
I want to get the first record and last record in an array. I don't
want any other records, but am not finding how to do it. What I am
doing is pulling out information from a database, where the sql query
would have a result much like this:
10
11
12
13
14
15
16
And I want to grab the first and last items in the array, so in this
case, 10 and 16.
RTFM.....
On Fri, 16 Nov 2007 14:00:23 +0100, Krustov <me@privacy.net wrote:
<comp.lang.ph p>
<Rik Wasmus>
<Fri, 16 Nov 2007 00:19:06 +0100>
<op************ ***@metallium.l an>
I want to get the first record and last record in an array. I don't
want any other records, but am not finding how to do it. What I am
doing is pulling out information from a database, where the sql query
would have a result much like this:
10
11
12
13
14
15
16
And I want to grab the first and last items in the array, so in this
case, 10 and 16.
RTFM.....
...and the answer was below that line..
Yes - how dare a user ask for php help on a php newsgroup .
What?
I stated: Read The Fine Manual, for instane, when working with arrays, one
would think to look at the array functions, <http://nl2.php.net/array>.
Try to find to find the text 'first' and 'last' on that page (two terms
the op literally used), and he'd have the answer.
Stating this could be easily found in the manual, and encouraging posters
to use it, helps them more in the long run then just easy answers.
Please don't toppost.
--
Rik Wasmus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Droopy |
last post by:
Hi,
I show some events to user in the GUI.
I am using a listbox but I don't know if it is the best choice.
I would like to show only n last events.
Should I, as soon as n items are displayed, remove the first one and add
the new one ?
Thanks in advance for your help.
|
by: Tony |
last post by:
I have this code:
Dim elementi() As String = Split(book, "pages")
I have to do remove first item from array elementi ... any help? Thanks
|
by: bdtmike |
last post by:
I'm using the GridView control and have the Mode of the Pager set to
"NumericFirstLast". However, when there are several pages to display,
the pager shows only page numbers--and no First/Last buttons. First of
all, is this a bug or am I doing something stupid? Secondly, can I
override the page numbers using my own template?
I'm using the latest Visual Studio 2005
Thanks.
|
by: Jared.Holsopple |
last post by:
Hi all,
I have a dynamically allocated array of doubles in VC++ .NET. When I
view the array in the watch window with "arrayName, 10", it displays
the correct value for arrayName, but arrayName through
arrayName are all zeros. Note that arrayName is actually double*,
and not double.
When I print out the array to the screen using printf, the correct
(non-zero) values are displayed. I'd rather not dump a bunch of
|
by: Tony Ciconte |
last post by:
Does anyone know of or have any VBA code or similar logic that can
help distinguish similar first/last name combinations? For example, we
would like to prompt the user of a possible match when any of the
first/last names Robert Smith, or Bob Smith, or Robt. Smith are used
during data entry. All that is necessary is to alert the user so that
they can review any appropriate existing records.
We have done several google searches without any...
| |
by: Janick Bernet |
last post by:
I just stumbled upon this olap function and wondered why the "NULLS
FIRST/LAST" clause is not possible in normal order by but only using
row_number() over(). Sure, I can do a
SELECT *, row_number() over(ORDER BY col1 ASC NULLS FIRST) AS rn FROM
tab1 ORDER BY rn
to get what I want, but its awfully complicated. (Interestingly, the
optimizer rewrites above order by in an ugly ORDER BY CASE WHEN col1
is NULL THEN 0 ELSE 1, col1)
Anyone...
|
by: gregpinero |
last post by:
I'm running code via the "exec in context" statement within a much
larger program. What I would like to do is capture any possible
errors and show a pretty traceback just like the Python interactive
interpreter does, but only show the part of the traceback relating to
the code sent to exec.
For example here is the code I'm using:
try:
exec code
|
by: mab464 |
last post by:
I have this code on my WAMP server running on my XP machine
if ( isset( $_POST ) )
{
for($i=0; $i<count($_POST);$i++)
{
if ($ans != NULL )
$ans .= ", " . $_POST ; // Not the first
element so append a comma
|
by: Claus Mygind |
last post by:
I create an array like this
$dispArray = array ("FIRST","LAST","name","ID","DIRECTPHON","MOBILE","MRMRS","myKey");
I search on the array like this:
if(array_search ( $key , $searchArray )){....}
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |