Soupy Posted February 7, 2010 Share Posted February 7, 2010 Hello all, I'm having a bit of a problem with this bit of code. You see, I have an array foo->bar->baz. I know what foo and bar are, but I do not know the value of baz. It's actually a response from a SOAP request. I need to write an if statement using baz, which I do not know the value of. How do I do this? For example, let's say Person->Male->key // this last one could be Bobby, Timmy, or Jimmy. if (Person->Male->key == Bobby) { do something; } Anyone know how to get around this? I hope I was clear enough. Thanks, Soupy Quote Link to comment https://forums.phpfreaks.com/topic/191207-question-on-creating-an-if-statement-using-the-value-of-a-key-in-an-array/ Share on other sites More sharing options...
MadTechie Posted February 7, 2010 Share Posted February 7, 2010 if Male only contains 1 entry then you could do this if ((current($array['Person']['Male']) == "Bobby"){ // do something } if not you could use a foreach loop Quote Link to comment https://forums.phpfreaks.com/topic/191207-question-on-creating-an-if-statement-using-the-value-of-a-key-in-an-array/#findComment-1008133 Share on other sites More sharing options...
Soupy Posted February 7, 2010 Author Share Posted February 7, 2010 Perfect, thank you very much. I didn't know about that function. D: Quote Link to comment https://forums.phpfreaks.com/topic/191207-question-on-creating-an-if-statement-using-the-value-of-a-key-in-an-array/#findComment-1008259 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.