473,387 Members | 1,899 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,387 software developers and data experts.

arrays: howto convert assoc to numeric


Folks,

If I have a numeric array similar to the following:

$tmpArray[0]="alpha";
$tmpArray[1]="beta";
$tmpArray[2]="charlie";

I can break it down like so

list($first,$second,$third)=$tmpArray;

This would mean $first="alpha", $second="beta" and $third="charlie"

However, when I have an associate array like so

$tmpArray["one"]="alpha";
$tmpArray["two"]="beta";
$tmpArray["three"]="charlie";

and do

list($first,$second,$third)=$tmpArray;

Then $first, $second, $third do not have values - Can someone give me an
environmentally friendly workaround to make this work? I can think of
explodes/implodes and a number of other methods, but I had believed I could
reference the first element in an associate array with a zero... and the
next with a numeric one, but that does not seem to be the case...

all help, via the newsgroup would be much appreciated, thanx

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?
Jul 17 '05 #1
2 4030
Hi Randell,

what about using array_values() to convert the array
into a an array with numeric indices?

Greetings from Frankfurt/Germany,

Fabian Wleklinski
Jul 17 '05 #2

"Fabian Wleklinski" <Wl*************@eWorks.de> wrote in message
news:bm********@library1.airnews.net...
Hi Randell,

what about using array_values() to convert the array
into a an array with numeric indices?

Greetings from Frankfurt/Germany,

Fabian Wleklinski

Danke! oder "lovely juvely" von Irish man im Canada.

(Im 1992 Ich habe mine wohn platz im Neuisenberg (oust Frankfurt bei 5km) -
meine deutsche is nicht gut aber ich habe gans gut times im Deutscheland)
Jul 17 '05 #3

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

Similar topics

3
by: David | last post by:
I have a script which retrives a list of files then reads the first two lines of each one of these files. Code: function retrieve_headers($username) { if(!file_exists('c:/'.$username)) return...
1
by: Jacek Generowicz | last post by:
The Numeric docs state that "Subclassing Numeric arrays is not possible due to a limitation of Python." What is this limitation? My first guess is that it is the unsbclassability of built-in...
3
by: Simon Foster | last post by:
I have some code which attempts to convert Python arrays (tuples of tuples of tuples...) etc. into C arrays with equivalent contents. The prototype code is shown below. My only question is, is...
3
by: doodle4 | last post by:
Hello all, I am trying to convert some C code into python. Since i am new to python, i would like to know how to deal with multidimensional arrays? Thanks, -Joe Here's a snippet of what i...
34
by: Christopher Benson-Manica | last post by:
If an array is sparse, say something like var foo=; foo=4; foo='baz'; foo='moo'; is there a way to iterate through the entire array? --
11
by: Soeren Sonnenburg | last post by:
Hi all, Just having started with python, I feel that simple array operations '*' and '+' don't do multiplication/addition but instead extend/join an array: a= >>> b= >>> a+b
3
by: Dan Sugalski | last post by:
I'm running into some problems with arrays in my SQL which're giving me fits. I've got some SQL statements that I'm issuing from my app using the PQexecParams() C call. All the parameters are...
11
by: Sheldon | last post by:
Hi, I have two arrays that are identical and contain 1s and zeros. Only the ones are valid and I need to know where both arrays have ones in the same position. I thought logical_and would work...
9
by: engteng | last post by:
How do I convert string to numeric in VB.NET 2003 ? Example convert P50001 to 50001 or 50001P to 50001 but if P is in middle then not convert. Regards, Tee
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...

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.