473,802 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating variables in a loop

Hi,
I want to create variables in a loop, each with a different name. Here
is the loop i'm using:
if (is_array($attr ibs)) {
echo "Attributes : <br />";
while(list($key ,$val) = each($attribs)) {
echo $key."has the value".$val."<b r>";

}
}

I want to create a variable with the name of each $key and contain the
value in $val.
Is this possible?

Jun 4 '07 #1
3 1511
Damo wrote:
Hi,
I want to create variables in a loop, each with a different name. Here
is the loop i'm using:
if (is_array($attr ibs)) {
echo "Attributes : <br />";
while(list($key ,$val) = each($attribs)) {
echo $key."has the value".$val."<b r>";

}
}

I want to create a variable with the name of each $key and contain the
value in $val.
Is this possible?
Possible (see http://www.php.net/manual/en/function.extract.php) but
pretty pointless. What's wrong with just array?
--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Jun 4 '07 #2
Cheers for the help. That did the trick

Jun 4 '07 #3
On Jun 4, 10:23 pm, Damo <cormacdeba...@ gmail.comwrote:
Cheers for the help. That did the trick
If that did the trick, you did something wrong designwise ;-)

But sometimes quick solutions are needed, and good design is not the
target / withing scope.

--
Jussi
Deep abstraction kills strong typing.
http://disczero.com
http://naamio.net
http://hoffburger.com

Jun 5 '07 #4

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

Similar topics

1
1311
by: John Smith | last post by:
This might be an absurd question, but is it possible to create variables on the fly? For example, if I have an array of values myArray(0) = "foo" myArray(1) = "bar" myArray(2) = "foobar" I would like to loop through the array and create variables named
10
10753
by: Dee | last post by:
Is C++ the best language to create a Windows based Instant Messenger? Something along the lines of MSN Messenger, ICQ, Yahoo Chat, etc? Are there any downloadable full or trial SDK's out there? I used to use Visual Basic a long time ago but want to create the fastest, easiest for the end user to install, most reliable software program possible
9
3097
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Declare your object variables
2
1561
by: Dave Monk | last post by:
Hi, I'm reasonably proficient in PHP but have been asked how to do something which has got me stumped. Hence, my posting: I want to create a small number of variables, $pos1, $pos2 ... $pos5 within a loop and assign them values from an array, but creating the variable names with incrementing numbers, well I've no idea how the PHP syntax for it works.
4
1595
by: =?Utf-8?B?VG9kZCBKYXNwZXJz?= | last post by:
Hey guys, Is there ANY way to accomplish this: (see below)? Basically, I want to have a loop (a < 3 is just for testing purposes, it will be an underermined amount). In this loop, I want to be able to create a new cell each time. In this cell, I want the variable name to change. Is this at ALL possible? I've never been able to figure this out in some of the other languages. Any help would GREATLY be appreciated.
1
2490
by: joe_doufu | last post by:
I'm creating a page with multiple "widgets", each with its own XMLHttpRequest object, so the user can play with the widgets in parallel. The widgets are enclosed in divs with class "widget" and a unique ID which tells me the name of the PHP file for the widget. Each widget should be able to access its PHP file with GET and POST methods, and to re-draw its innerHTML on response. I am using a simple Ajax library called XHConn...
13
12805
by: jkimbler | last post by:
As part of our QA of hardware and firmware for the company I work for, we need to automate some testing of devices and firmware. Since not everybody here knows C#, I'm looking to create a new scripting language that makes writing automated tests simpler. Really, I'm looking to kind of abstract the power of the C# language into a simpler language that's easier to learn. The script files would be interpreted by a script interpreter...
14
2116
by: tdahsu | last post by:
I have twenty-five checkboxes I need to create (don't ask): self.checkbox1 = ... self.checkbox2 = ... .. .. .. self.checkbox25 = ... Right now, my code has 25 lines in it, one for each checkbox, since
6
5637
by: AMP | last post by:
Hello, I am trying to do the following with a loop because the amount of channels can change. uint Chan_1 = 0; uint Chan_2 = 0; uint Chan_3 = 0; uint Chan_4 = 0; uint Chan_5 = 0; uint Chan_6 = 0; uint Chan_7 = 0;
0
9699
marktang
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...
0
10305
jinu1996
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...
0
10063
tracyyun
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...
0
9115
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
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...
0
6838
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();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2966
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.