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

Can I get the value from an assoc array that is returned by a function...in one statement?

I want to be able to get the present year in one statement. I know that I
can do it this way:

$y = getdate();
echo 'year='.$y['year'];

But, I want to do something like:

echo 'year='.getdate()['year']; # BAD, I know

Ideas?

TIA,

Larry Woods
Jan 12 '06 #1
6 1331
lwoods wrote:
I want to be able to get the present year in one statement.


http://php.net/date

--
E. Dronkert
Jan 12 '06 #2
NC
lwoods wrote:

I want to be able to get the present year in one statement. I know that I
can do it this way:

$y = getdate();
echo 'year='.$y['year'];

But, I want to do something like:

echo 'year='.getdate()['year']; # BAD, I know


There's no need to use getdate() if all you want is year. Consider
this:

echo date('Y');

Cheers,
NC

Jan 12 '06 #3
lwoods wrote:
I want to be able to get the present year in one statement. I know that I
can do it this way:

$y = getdate();
echo 'year='.$y['year'];

But, I want to do something like:

echo 'year='.getdate()['year']; # BAD, I know

Ideas?


echo 'year=', date('Y');
If your problem is what you used for the subject
Can I get the value from an assoc array that is returned by a
function...in one statement?
then there's a lovely solution proposed by ... searching ...
.... Robin Goodall on a similar problem I posted a long way back.

<http://groups.google.com/group/comp.lang.php/browse_thread/thread/96568bc7c66ad4a/ce59a0c7758992b9>
which I shortened to <http://shorterlink.com/?S9KW1T>

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jan 12 '06 #4
Thanks, all....

I'll follow up on the Goodall solution, Pedro.

Larry

"Pedro Graca" <he****@dodgeit.com> wrote in message
news:sl*******************@ID-203069.user.individual.net...
lwoods wrote:
I want to be able to get the present year in one statement. I know that
I
can do it this way:

$y = getdate();
echo 'year='.$y['year'];

But, I want to do something like:

echo 'year='.getdate()['year']; # BAD, I know

Ideas?


echo 'year=', date('Y');
If your problem is what you used for the subject
Can I get the value from an assoc array that is returned by a
function...in one statement?
then there's a lovely solution proposed by ... searching ...
... Robin Goodall on a similar problem I posted a long way back.

<http://groups.google.com/group/comp.lang.php/browse_thread/thread/96568bc7c66ad4a/ce59a0c7758992b9>
which I shortened to <http://shorterlink.com/?S9KW1T>

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!

Jan 12 '06 #5
Thanks

Larry

"Ewoud Dronkert" <fi*******@lastname.net.invalid> wrote in message
news:m3********************************@4ax.com...
lwoods wrote:
I want to be able to get the present year in one statement.


http://php.net/date

--
E. Dronkert

Jan 12 '06 #6
Thanks

Larry
"NC" <nc@iname.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
lwoods wrote:

I want to be able to get the present year in one statement. I know that
I
can do it this way:

$y = getdate();
echo 'year='.$y['year'];

But, I want to do something like:

echo 'year='.getdate()['year']; # BAD, I know


There's no need to use getdate() if all you want is year. Consider
this:

echo date('Y');

Cheers,
NC

Jan 12 '06 #7

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

Similar topics

11
by: Stefan Richter | last post by:
Hi, I want to create an associative Array with a PHP variable (article ID) as Key and another associative array as it's value. How do I instanciate it, how can I fill it? I want something...
6
by: Jim SUTTON | last post by:
I am sure I have had this problem before and can't remember what the fix is... The documentation says that an array can be returned from a function provided you do the following:- 1. Declare...
15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
5
by: Andrew Poulos | last post by:
If I'm searching for an occurance of a value in a multi-dimensional array how can I get it's index returned as an array, if found? For example, if: foo = new Array(); foo = , 5, , 9, 10]; ...
9
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval...
7
by: The87Boy | last post by:
Is there any ways to make a function like system(), which returns more than one value (true or false) and (the array)
7
by: Terry Olsen | last post by:
How do I get this to work? It always returns False, even though I can see "This is True!" in the debug window. Do I have to invoke functions differently than subs? Private Delegate Function...
5
by: KDawg44 | last post by:
Hi, Is there a way to get a multidimensional associative array with the entire result set? I would like to get a an array like this: resultsArray How can I accomplish this? Can I do...
5
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return...
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?
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...

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.