Title: PHP If Statement Help
Last modified: August 21, 2016

---

# PHP If Statement Help

 *  Resolved [jslom](https://wordpress.org/support/users/jslom/)
 * (@jslom)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/php-if-statement-help/)
 * Hello, and thank you for such a wonderful plugin!
 * I have successfully used some if statements to pull information and display an
   image depending on the users selection, but need help with the last one.
 * First, this is one of the examples of a field I am pulling..
 *     ```
       <?php
       $platform = xprofile_get_field_data( 'What platform do you play on the most?', $member_id ); if ( $platform == 'Playstation 3' ) echo '<img src="ps3-icon.png">'
       ?>
       ```
   
 * Where “What platform do you play on the most?” is the name of my selection box.
   The one above works fine for a drop down selection box.
 * I am trying to do the same if statement, but with a checkbox setup and it doesn’t
   seem to use the same code.
 * I’ve tried a few variations of code like below, but have been unsuccessful on
   getting it to display.
 *     ```
       <?php
       xprofile_get_field_data( 'What Games Are You Frequently Playing?', $member_id ); if ( $games == (isset($_POST['Call Of Duty: Ghosts'])) && $_POST["Call Of Duty: Ghosts"] == 1 ) echo '<img src="codghosts.png">'
       ?>
       ```
   
 * Any help would be wonderful, thanks! Also if you notice anything I am doing wrong,
   please let me know I am still learning!
 * [http://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/](http://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/php-if-statement-help/#post-4454456)
 * Hi,
 * This is not in the scope of my plugin…
 * Checkboxes are stored as an array. If you make a var_dump of the data like this:
 * `<?php $games = xprofile_get_field_data( 'What Games Are You Frequently Playing?',
   $member_id ); var_dump($games); ?>`
 * You will see something like this:
 *     ```
       array (size=2)
         0 => string 'Call of Duty' (length=12)
         1 => string 'Other games' (length=11)
       ```
   
 * So, to check against an array you must do this:
 * `if (in_array('Call Of Duty: Ghosts', $games)) echo '<img src="codghosts.png"
   >';`
 *  Thread Starter [jslom](https://wordpress.org/support/users/jslom/)
 * (@jslom)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/php-if-statement-help/#post-4454562)
 * Thank you!
 * I had the code last night that worked, and now I seemed to have not saved it 
   lol
 * I will try and figure it out again with the code above!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP If Statement Help’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/buddypress-xprofile-custom-fields-
   type.svg)
 * [Buddypress Xprofile Custom Fields Type](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/)
 * [Active Topics](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [jslom](https://wordpress.org/support/users/jslom/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/php-if-statement-help/#post-4454562)
 * Status: resolved