hi there)
guys, please tell me - is it any way to make associative array in php without assignment values to the arrays elements?
in my situation i need to read indexes names from txt-file -so i can't immediatly give them values.....what will you advice in this situation?
Is there any way to avoid NULL assignment ?

big thanks in advance)

Recommended Answers

All 3 Replies

Hm, with null/false/-1/'' as value you can display the array:

$a = array('a' => false, 'b' => '', 'c' => '1a');
print_r($a);

Just make sure to not run array_filter() against this array or those will be removed.

commented: +++++++++++ +3

so - as i understand there isn't any way to write code without any temporary assignments ? am i right?)

I'm sorry but I don't understand, maybe because English is not my main language, can you provide an example of what you would like to do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.