frankdm Posted July 24, 2016 Share Posted July 24, 2016 Hello all, I got a value in a variable (works fine), now I want to check if that value is NOT some things and then do something if it is not, here is what I have so far: (the two lines between the empty lines are the new bit, the other lines are old and work fine) if ($atts['excerpt'] == 'true') { $vargooglelink = "http://www.google.com/images?q="; $varproducttitle = get_the_title(); $vargooglelinkend = " house"; $varbundlecheck = get_the_ID(); IF $varbundlecheck IS NOT 5415 IS NOT 5961 IS NOT 4710 THEN DO $varcomplete = $vargooglelink . $varproducttitle . $vargooglelinkend; $content .= "<td> <a href='$varcomplete' target=_blank><img src=wp-content/custom/imageicon.png /></a> </td>"; } break; Quote Link to comment https://forums.phpfreaks.com/topic/301574-php-if-not-variable-then-do/ Share on other sites More sharing options...
frankdm Posted July 24, 2016 Author Share Posted July 24, 2016 I adapted it to the best of my abilities, it is not erroring but it is not working either: case 'excerpt': if ($atts['excerpt'] == 'true') { $vargooglelink = "http://www.google.com/images?q="; $varproducttitle = get_the_title(); $vargooglelinkend = " house"; $varbundlecheck = get_the_ID(); if ( !in_array($varbundlecheck, array('5415','5961','4710'), true ) ) { $varcomplete = $vargooglelink . $varproducttitle . $vargooglelinkend; $content .= "<td> <a href='$varcomplete' target=_blank><img src=wp-content/custom/imageicon.png /></a> </td>"; } } break; Quote Link to comment https://forums.phpfreaks.com/topic/301574-php-if-not-variable-then-do/#findComment-1534940 Share on other sites More sharing options...
Solution ginerjm Posted July 24, 2016 Solution Share Posted July 24, 2016 Is the ID a number or a string? Be sure you are comparing correctly. Quote Link to comment https://forums.phpfreaks.com/topic/301574-php-if-not-variable-then-do/#findComment-1534943 Share on other sites More sharing options...
frankdm Posted July 24, 2016 Author Share Posted July 24, 2016 Is the ID a number or a string? Be sure you are comparing correctly. Hey it is a number, i think (it is the ID of a product in woocommerce), I have no idea how that is returned, I guess as a number. Quote Link to comment https://forums.phpfreaks.com/topic/301574-php-if-not-variable-then-do/#findComment-1534948 Share on other sites More sharing options...
frankdm Posted July 24, 2016 Author Share Posted July 24, 2016 Is the ID a number or a string? Be sure you are comparing correctly. Hey, I found the answer, I had to remove the ' icons! Quote Link to comment https://forums.phpfreaks.com/topic/301574-php-if-not-variable-then-do/#findComment-1534952 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.