I have an array as follows
$sounds = array();
$sounds['sound1'] = "fishes/1/sound.php";
$sounds['sound2'] = "fishes/2/sound.php";
$sounds['sound3'] = "fishes/3/sound.php";
$sounds['sound4] = "fishes/4/sound.php";
$sounds['sound5] = "fishes/5/sound.php";
$sounds['sound11] = "bears/1/sound.php";
etc etc......
What I want to be able to do have turn the above into this:
include ("sounds/fishes/1/sound.php");
include ("sounds/fishes/2/sound.php");
print ("<br>divider<br>");
include ("sounds/fishes/3/sound.php");
include ("sounds/fishes/4/sound.php");
print ("<br>divider<br>");
include ("sounds/fishes/5/sound.php");
include ("sounds/birds/1/sound.php");
etc etc
I'm totally clueless as to how I might acheive it, especially including the
"dividers" every two includes. Surely one of you clever folk gotta be able
to spoon feed it to me? ;) 9 1959
On Tue, 23 Mar 2004 16:46:55 +0000, mark wrote: I'm totally clueless as to how I might acheive it, especially including the "dividers" every two includes. Surely one of you clever folk gotta be able to spoon feed it to me? ;)
no spoon feeding until you try harder. Some pointers, though:
Use
foreach($sounds as $key => $value){
}
and
the modulus operator (%) to determine if two rows have passed.
later....
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Website | http://www.wse.jhu.edu/newtnotes/
"Jeffrey Silverman" <je*****@jhu.edu> wrote in message
news:pa****************************@jhu.edu... no spoon feeding until you try harder. Some pointers, though:
Use
foreach($sounds as $key => $value){ }
and
the modulus operator (%) to determine if two rows have passed.
thanks for the reply, but honestly I'm useless at PHP, any chance you could
tell me the answer really? pretty please?
mark wrote: "Jeffrey Silverman" <je*****@jhu.edu> wrote in message news:pa****************************@jhu.edu...
no spoon feeding until you try harder. Some pointers, though:
Use
foreach($sounds as $key => $value){ }
and
the modulus operator (%) to determine if two rows have passed.
thanks for the reply, but honestly I'm useless at PHP, any chance you could tell me the answer really? pretty please?
You're not gonna get any better at PHP if everyone does all the work for
you. ;)
The foreach() will loop thru your $sounds array and pull the key/value
pairs and assign them to $key and $value. Then it's up to you to do
whatever you want with the two variables.
For the modulus (remainder of division), you could use a counter and
check if the counter is evenly divisible by 2 ($ctr % 2). If it is,
output your image/text/hr whatever. If not, continue the loop.
-Jay
"Jay Moore" <ad*****@isp.tld> wrote in message
news:Tg******************@twister.rdc-kc.rr.com... mark wrote:
You're not gonna get any better at PHP if everyone does all the work for you. ;)
The foreach() will loop thru your $sounds array and pull the key/value pairs and assign them to $key and $value. Then it's up to you to do whatever you want with the two variables.
For the modulus (remainder of division), you could use a counter and check if the counter is evenly divisible by 2 ($ctr % 2). If it is, output your image/text/hr whatever. If not, continue the loop.
Excellent! I got it now and it works :) many thanks....
You don't happen to know how I can have the array come out upside down do
you too? pretty pretty please?
"Pedro Graca" <he****@hotpop.com> wrote in message
news:c3*************@ID-203069.news.uni-berlin.de... mark wrote (edited): How can I have the array come out upside down?
http://www.php.net/array_reverse
Also look at all the other array functions. They're wonderful :)
thanks, If i try array_rand or revervse I get:
Warning: Wrong parameter count for array_rand on line 3:
:/
mark wrote: "Jay Moore" <ad*****@isp.tld> wrote in message news:Tg******************@twister.rdc-kc.rr.com...
mark wrote:
You're not gonna get any better at PHP if everyone does all the work for you. ;)
The foreach() will loop thru your $sounds array and pull the key/value pairs and assign them to $key and $value. Then it's up to you to do whatever you want with the two variables.
For the modulus (remainder of division), you could use a counter and check if the counter is evenly divisible by 2 ($ctr % 2). If it is, output your image/text/hr whatever. If not, continue the loop.
Excellent! I got it now and it works :) many thanks....
You don't happen to know how I can have the array come out upside down do you too? pretty pretty please?
http://us2.php.net/manual/en/function.arsort.php http://us2.php.net/manual/en/function.krsort.php
"Jay Moore" <ad*****@isp.tld> wrote in message
news:1_******************@twister.rdc-kc.rr.com... http://us2.php.net/manual/en/function.krsort.php
that works, although I have some problems because my array values are like
this 1, 11, 111 instead of 001, 011, 111 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nathan Rose |
last post by:
Here's my problem. I am reading from a text file using this:
if (!file_exists($file))
{
echo "Don't exist\n";
return false;
}
$fd = @fopen($file, 'r');
if (!is_resource($fd))
|
by: JackM |
last post by:
Let me attempt to explain my problem. I have a crude php script that
takes a text list of songs that was generated by an mp3 list program and
translates each entry into the form where they can be...
|
by: VK |
last post by:
A while ago I proposed to update info in the group FAQ section, but I
dropped the discussion using the approach "No matter what color the cat
is as long as it still hounts the mice". Over the last...
|
by: Alexei A. Frounze |
last post by:
Hi all,
I have a question regarding the gcc behavior (gcc version 3.3.4).
On the following test program it emits a warning:
#include <stdio.h>
int aInt2 = {0,1,2,4,9,16};
int aInt3 =...
|
by: George |
last post by:
Sub ExcelToListBox()
Dim xRange As Object
Dim ary
Dim xValue As String
xRange = oXL.Range("A1:A9") 'has letters A-H
ary = xRange.value
xValue = ary(3, 1) 'xValue = C...
| |
by: RyanTaylor |
last post by:
I have a final coming up later this week in my beginning Java class and my
prof has decided to give us possible Javascript code we may have to write.
Problem is, we didn't really cover JS and what...
|
by: helldiversafe-news |
last post by:
Hi all,
I will use a apache soap service with an .net c# client and have a
problem with an complex array:
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope...
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
Hi Gurus,
I need to transfer a jagged array of byte by reference to unmanaged
function, The unmanaged code should changed the values of the array, and when
the unmanaged function returns I need...
|
by: anklos |
last post by:
Hi~!
I met a problem on printing out a kind of hash array.
i.e @array=(1,2,3,4,5,6);
$array{$term}=1;
diffent $i may contain diifernt $term(more than one term for each $i)
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
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.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| | |