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

array query

$record= array(
"product"=>array(
array("name"=>"apple","price"=>30.5),
array("name"=>"orange","price"=>20)
)
);

echo array_read($record, "[product][0][price]") //out 30.5

print_r (array_read($record, "[product][*][name]")) //out
array("apple","orange")

echo array_read($record, "[product][*=>(name=orange)][price]") //out
20

echo array_read($record, "[product][(*)=>(price>20)][name]") //out
"apple"
echo array_read($record, "[product][(0)=>(name=orange)][price]") //out
null
echo array_read($record, "[product][(1)=>(name=orange)][price]") //out
20
http://pleiadesworks.blogspot.com/20...ad-arrays.html

Apr 15 '07 #1
7 1319
Francis S wrote:
$record= array(
"product"=>array(
array("name"=>"apple","price"=>30.5),
array("name"=>"orange","price"=>20)
)
);

echo array_read($record, "[product][0][price]") //out 30.5

print_r (array_read($record, "[product][*][name]")) //out
array("apple","orange")

echo array_read($record, "[product][*=>(name=orange)][price]") //out
20

echo array_read($record, "[product][(*)=>(price>20)][name]") //out
"apple"
echo array_read($record, "[product][(0)=>(name=orange)][price]") //out
null
echo array_read($record, "[product][(1)=>(name=orange)][price]") //out
20
http://pleiadesworks.blogspot.com/20...ad-arrays.html
array_read() is not in my PHP manual. I don't really see the points you
are trying to make here or on your blog. You're surely not just spamming
for attention?

Sh.
Apr 15 '07 #2
"Francis S" <fr********@gmail.comwrote in message
news:11*********************@p77g2000hsh.googlegro ups.com...
$record= array(
"product"=>array(
array("name"=>"apple","price"=>30.5),
array("name"=>"orange","price"=>20)
)
);

echo array_read($record, "[product][0][price]") //out 30.5

print_r (array_read($record, "[product][*][name]")) //out
array("apple","orange")

echo array_read($record, "[product][*=>(name=orange)][price]") //out
20

echo array_read($record, "[product][(*)=>(price>20)][name]") //out
"apple"
echo array_read($record, "[product][(0)=>(name=orange)][price]") //out
null
echo array_read($record, "[product][(1)=>(name=orange)][price]") //out
20
http://pleiadesworks.blogspot.com/20...ad-arrays.html
>
Is this one of those games where you offer the answer so someone can find
the question?
Apr 15 '07 #3
On Apr 15, 1:22 pm, Schraalhans Keukenmeester <bitbuc...@invalid.spam>
wrote:
Francis S wrote:
$record= array(
"product"=>array(
array("name"=>"apple","price"=>30.5),
array("name"=>"orange","price"=>20)
)
);
echo array_read($record, "[product][0][price]") //out 30.5
print_r (array_read($record, "[product][*][name]")) //out
array("apple","orange")
echo array_read($record, "[product][*=>(name=orange)][price]") //out
20
echo array_read($record, "[product][(*)=>(price>20)][name]") //out
"apple"
echo array_read($record, "[product][(0)=>(name=orange)][price]") //out
null
echo array_read($record, "[product][(1)=>(name=orange)][price]") //out
20
http://pleiadesworks.blogspot.com/20...asier-way-to-r...

array_read() is not in my PHP manual. I don't really see the points you
are trying to make here or on your blog. You're surely not just spamming
for attention?

Sh.
just an idea without using foreach.. . maybe someone can proposals a
better one

Apr 15 '07 #4
On Apr 15, 7:38 am, "Francis S" <francis...@gmail.comwrote:
>
just an idea without using foreach.. . maybe someone can proposals a
better one
Yeah -- use DOM and XPath.

Apr 15 '07 #5
Francis S wrote:
$record= array(
"product"=>array(
array("name"=>"apple","price"=>30.5),
array("name"=>"orange","price"=>20)
)
);

echo array_read($record, "[product][0][price]") //out 30.5

print_r (array_read($record, "[product][*][name]")) //out
array("apple","orange")

echo array_read($record, "[product][*=>(name=orange)][price]") //out
20

echo array_read($record, "[product][(*)=>(price>20)][name]") //out
"apple"
echo array_read($record, "[product][(0)=>(name=orange)][price]") //out
null
echo array_read($record, "[product][(1)=>(name=orange)][price]") //out
20
http://pleiadesworks.blogspot.com/20...ad-arrays.html
Seems to be a solution to a non-existent problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 15 '07 #6
Francis S wrote:
On Apr 15, 1:22 pm, Schraalhans Keukenmeester <bitbuc...@invalid.spam>
wrote:
>Francis S wrote:
>>$record= array(
"product"=>array(
array("name"=>"apple","price"=>30.5),
array("name"=>"orange","price"=>20)
)
);
echo array_read($record, "[product][0][price]") //out 30.5
print_r (array_read($record, "[product][*][name]")) //out
array("apple","orange")
echo array_read($record, "[product][*=>(name=orange)][price]") //out
20
echo array_read($record, "[product][(*)=>(price>20)][name]") //out
"apple"
echo array_read($record, "[product][(0)=>(name=orange)][price]") //out
null
echo array_read($record, "[product][(1)=>(name=orange)][price]") //out
20
http://pleiadesworks.blogspot.com/20...asier-way-to-r...
array_read() is not in my PHP manual. I don't really see the points you
are trying to make here or on your blog. You're surely not just spamming
for attention?

Sh.

just an idea without using foreach.. . maybe someone can proposals a
better one
And what does array_read() look like in that case? To be honest I had
the same feeling Jerry had, I don't really see a realistic problem being
solved, but I kind'a hoped the magic would be in your array_read(). But
after rereading I still don't see an implementation.

But then I've been known to make a fool of myself more than once, so I'm
here with two leges ready for pulling. Surprise me!

Sh.
Apr 15 '07 #7

"Vince Morgan" <vi****@REMOVEoptusnet.com.auwrote in message
news:46***********************@news.optusnet.com.a u...
| "Francis S" <fr********@gmail.comwrote in message
| news:11*********************@p77g2000hsh.googlegro ups.com...
| $record= array(
| "product"=>array(
| array("name"=>"apple","price"=>30.5),
| array("name"=>"orange","price"=>20)
| )
| );
| >
| echo array_read($record, "[product][0][price]") //out 30.5
| >
| print_r (array_read($record, "[product][*][name]")) //out
| array("apple","orange")
| >
| echo array_read($record, "[product][*=>(name=orange)][price]") //out
| 20
| >
| echo array_read($record, "[product][(*)=>(price>20)][name]") //out
| "apple"
| echo array_read($record, "[product][(0)=>(name=orange)][price]") //out
| null
| echo array_read($record, "[product][(1)=>(name=orange)][price]") //out
| 20
| >
| >
| >
|
http://pleiadesworks.blogspot.com/20...ad-arrays.html
| >
| Is this one of those games where you offer the answer so someone can find
| the question?

BINGO !!!

btw, you are the winner! you win via answer proximity...'WTF is the problem'
was what trebec was expecting, however 'wtf is the question' is close
enough.

:)
Apr 16 '07 #8

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

Similar topics

6
by: supercomputer | last post by:
I am using this function to parse data I have stored in an array. This is what the array looks like: , , , , , , , , , , , , , , , , , , , , , , , ] This is the code to parse the array:
11
by: Jeevan | last post by:
Hi, I have some data which I am getting from a socket. I am currently storing the data in an array (so that future reading of the data will be fast as it will be in RAM instead of hard disk)....
8
by: Andy Kriger | last post by:
I would like to select strings from a table and return them as an array For example, select new_array(name) from my_tbl would return String { name1, name2, name3, etc } Is this possible with...
3
by: deko | last post by:
This will take a bit of explanation, so please bear with me... The code below dynamically builds hyperlinks using two queries - query A and query B. I want to optimize the code so I can omit...
1
by: DavidB | last post by:
I am working with a database and I would like to be able to populate an array at run time and then use the values that were pushed into the array as criteria for a select query. It seems that this...
13
by: Karl Groves | last post by:
I'm missing something very obvious, but it is getting late and I've stared at it too long. TIA for responses I am writing a basic function (listed at the bottom of this post) that returns...
1
by: lukemack | last post by:
Hi, I have an array in the following format : Array ( =Array ( =Array (
1
by: Kurt Jakobsen | last post by:
Hello, I have a MySQL query that I want to perform in a utility (not page) class. This query should fill up an array of string's and then return the array to the calling class. The array will then...
4
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be...
3
by: robin1983 | last post by:
Dear All, I have a query regarding the array. The problem is that I want fetch some value from a table and store the value in an array and again want to run one more query on the basis of the...
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
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?
1
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...
0
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,...
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
Oralloy
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,...
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...
0
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...

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.