mongoose0031800 Posted August 13, 2011 Share Posted August 13, 2011 Hey all, Why isn't my script outputting any value when I use the following code? $item_count = count($_POST['qty']); die($item_count-1); I've already tested that $_POST['qty'] isn't empty. If I output count($_POST['qty']) then it displays a value. But if I try to subtract a value of 1, no value comes out. I swear I've seen people add/subtract values from a count function...am I wrong about this? Thanks! mongoose Quote Link to comment https://forums.phpfreaks.com/topic/244706-php-count-function/ Share on other sites More sharing options...
jcbones Posted August 13, 2011 Share Posted August 13, 2011 <?php $_POST['qty'][] = 3; $_POST['qty'][]=4; if(!empty($_POST['qty'])) { $item_count = COUNT($_POST['qty']) - 1; } echo $item_count; //should echo 1; ?> Quote Link to comment https://forums.phpfreaks.com/topic/244706-php-count-function/#findComment-1256901 Share on other sites More sharing options...
mongoose0031800 Posted August 13, 2011 Author Share Posted August 13, 2011 Thanks its working now! Quote Link to comment https://forums.phpfreaks.com/topic/244706-php-count-function/#findComment-1256911 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.