473,325 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

simple arrays

Hello everyone. I'm trying to learn php, since it seems to be more efficent
than perl. Could someone show me how I can simply print out every element of
an array, with a newline between each element? I would really appreciate
this.

Thanks,
Matt
Jul 16 '05 #1
2 2259
uws
I <qS*********************@twister.tampabay.rr.com >, Jason skrev:
$array = array('test', 'test1', 'test2');
foreach($array as $value) {
echo "$value\n";
}

$array = array('test', 'test1', 'test2');
foreach($array as $value) {
echo $value, "\n";
}

mvrgr, Wouter

--
uws mail uw*@xs4all.nl

so much we don't know :: even our own true face -- after forever
Jul 16 '05 #2
Jason wrote:
$array = array('test', 'test1', 'test2');
foreach($array as $value) {
echo "$value\n";
}


Or even:

$myArray = array('test','test2','test3');
print "<pre>";
print_r($myArray);
print "</pre>";

which would print:
Array
(
[0] => test
[1] => test2
[2] => test3
)

The good news is this even works with complex, multi dimensional arrays.
In your HTML source the linebreaks would be there, so you could use
print_r() only. To have the contents printed this way in HTML the
<pre>/</pre> tags do the trick.

--
//marius

Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jedispy | last post by:
Hello, I'm pretty new to PHP, and for starters I want to create a simple script for creating dynamic web pages. Here is how I want it to work: index.html has 4 thumbnail images on it. When users...
2
by: Westcoast Sheri | last post by:
Any way to do a simple delete from array? In other words, what would be the *easiest* (and fastest php runtime) way to delete "banana" from the following array: $my_array = array( "apple",...
13
by: Roy Riddex | last post by:
2nd post of the day! I'm just learning about Arrays at College and have met a problem. I have 5 text boxes for number input, a command button to add the numbers to the array, and a command button...
31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
7
by: jmac | last post by:
Greetings fellow programmers, I have created a C program that has a few bugs and would like to get some help with working them out. Here is a list of the problems that I am experiencing: -...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
9
by: niclane | last post by:
Hi, I was reading section 5.5 of Ritchie and Kernighan and saw the following: " ..... char amessage = "now is the time"; char *pmessage = "now is the time";
9
by: NewInTheGame | last post by:
I'm a beginner in VB.Net. I'm actually taking a class & so far I understand everything, but I suck when it comes to arrays. I'm sure that this is simple (I'm ashamed of asking :oops: )... I...
4
by: learnfpga | last post by:
Here is a little code I wrote to add the numbers input by the user.....I was wondering if its possible to have the same functionality without using dynamic arrays.....just curious..... ...
24
by: Michael | last post by:
Hi, I am trying to pass a function an array of strings, but I am having trouble getting the indexing to index the strings rather than the individual characters of one of the strings. I have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.