Hi,
I've got a complicated problem to solve. Say I have an indexed array
$array, with contents as follows:
'name' ='James'
'favefood' ='Spagbol'
'os' ='Debian GNU/Linux'
And say I want to create a list, that prints the name of each item,
and then its contents, like this:
name: James
favefood: Spagbol
os: Debian GNU/Linux
The only problem, I don't what the items in the array are called, so I
can't do this:
os: <?=$array['os']?>
Any ideas? It's got me stumped.
Thanks in advance,
--James Goode. 3 1470
jamesgoode <ja***@jgoode.co.ukwrote in news:1194465491.529347.23280
@d55g2000hsg.googlegroups.com:
Hi,
I've got a complicated problem to solve. Say I have an indexed array
$array, with contents as follows:
'name' ='James'
'favefood' ='Spagbol'
'os' ='Debian GNU/Linux'
And say I want to create a list, that prints the name of each item,
and then its contents, like this:
name: James
favefood: Spagbol
os: Debian GNU/Linux
The only problem, I don't what the items in the array are called, so I
can't do this:
os: <?=$array['os']?>
Any ideas? It's got me stumped.
Thanks in advance,
foreach($array as $key=>$value) {
echo "$key: $value <br>";
}
Also, as mentioned elsewhere, future-proof your code and lose the short
tags... no more <?= $myVar ?>, and only <?php echo $myVar; ?>
On Nov 7, 8:02 pm, Good Man <he...@letsgo.comwrote:
jamesgoode <ja...@jgoode.co.ukwrote in news:1194465491.529347.23280
@d55g2000hsg.googlegroups.com:
Hi,
I've got a complicated problem to solve. Say I have an indexed array
$array, with contents as follows:
'name' ='James'
'favefood' ='Spagbol'
'os' ='Debian GNU/Linux'
And say I want to create a list, that prints the name of each item,
and then its contents, like this:
name: James
favefood: Spagbol
os: Debian GNU/Linux
The only problem, I don't what the items in the array are called, so I
can't do this:
os: <?=$array['os']?>
Any ideas? It's got me stumped.
Thanks in advance,
foreach($array as $key=>$value) {
echo "$key: $value <br>";
}
Also, as mentioned elsewhere, future-proof your code and lose the short
tags... no more <?= $myVar ?>, and only <?php echo $myVar; ?>
Hi Good Man,
Thanks for your fast response, now I can continue with my project :-).
Regards,
--James
On Nov 7, 2:58 pm, jamesgoode <ja...@jgoode.co.ukwrote:
Hi,
I've got a complicated problem to solve. Say I have an indexed array
$array, with contents as follows:
'name' ='James'
'favefood' ='Spagbol'
'os' ='Debian GNU/Linux'
And say I want to create a list, that prints the name of each item,
and then its contents, like this:
name: James
favefood: Spagbol
os: Debian GNU/Linux
The only problem, I don't what the items in the array are called, so I
can't do this:
os: <?=$array['os']?>
Any ideas? It's got me stumped.
I often do this:
while (list($key, $val) = each($array)) {
echo "os: $key ";
}
If I have an array just input by a form, and I need to addslashes
before sending it to a database, this is quite useful:
while (list($key, $val) = each($formInputs)) {
$formInputs[$key] = addslashes($val);
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tim |
last post by:
Hello,
I'm extremely puzzled; I cannot figure out what I'm doing wrong. Here's
the situation. I would really appreciate any suggestions.
I'm modifying a shopping cart in the following way....
|
by: PyPK |
last post by:
What possible tricky areas/questions could be asked in Python based
Technical Interviews?
|
by: Danny |
last post by:
Hi there
I need help with a tricky problem.
I have a 2 dimensional array with qualities such as
ball size, ball color, ball weight.
Now I have to print out all the possible combinations of...
|
by: pras.vaidya |
last post by:
Hi , below given question was asked to me during an interview and i
figured it out little tricky . It would be a great help if anyone
could solve it.
Code : -
main()
{
char...
|
by: localhost |
last post by:
I have a string that looks like this:
"document.form1.textBox1.focus
();document.form1.textBox1.select();"
I want to replace the text between "document.form1."
and ".focus()",
as well as...
|
by: Mark Sandfox |
last post by:
I have a tricky control validation issue. I have probably designed this the
wrong way but here is what I have.
I have 6 TextBoxes; tbPN, tbA, tbC, tbS, tbZ, tbDOB and there are 20 of each
with...
|
by: ric_deez |
last post by:
Hi there, I would like to create a simple search form to allow users to
search for a job number based on a number of parameters. I think I
understand how to use parameteres associated with Stored...
|
by: Osiris |
last post by:
Just something I would like to share:
I just learned the hard way (2 days detective work on a bug) that foreach
loops are not at all like for loops, not intuitive at all. BEWARE: arrays
and...
|
by: claudfs |
last post by:
Hey Guys,
Ok here is my problem:
There is around 350 rows in the db.
All the variables $actor_id, $comment_id and $likes_id are all uid's for facebook users
Now i want to group and sum...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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: 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...
| |