tags:

views:

51

answers:

2

So I'm having a problem with arrays:

print_r($_POST['bank']);

produces the following output:

Array ( ['deposit'] => 30 ) 

However,

assert($_POST['bank']['deposit']==30);

which immediately follows print_r, fails. I feel like an idiot, but could someone help me out? Since nothing is changing the value of $_POST, I suppose my syntax is wrong, but I can't see it for the life of me.

A: 

Try doing

assert(intval($_POST['bank']['deposit']) == 30);
Sam Day
+2  A: 

Ugh, I just realized it.

assert($_POST['bank']['\'deposit\'']==30);

works fine, because "deposit" had had extra single quotes around it.

waiwai933
+1 for figuring it out
David Titarenco
or: `assert($_POST['bank']["'deposit'"]==30);`
Peter Ajtai