deansaddigh Posted March 30, 2010 Share Posted March 30, 2010 Hi, How would i do a size of array calculation so that i can conditionally do something. For example $discounts = $_POST["discounts"]; $sizeof_arr = sizeof($discounts); if ( sizeof_arr >0 ) { } else { } Does not work, get this error Notice: Use of undefined constant sizeof_arr - assumed 'sizeof_arr' in \\nas44ent\domains\l\languageschoolsuk.com\user\htdocs\admin\add_course_form_submit.php on line 22 Thanks in advance Link to comment https://forums.phpfreaks.com/topic/197018-size-of-array/ Share on other sites More sharing options...
hcdarkmage Posted March 30, 2010 Share Posted March 30, 2010 Hi, How would i do a size of array calculation so that i can conditionally do something. For example $discounts = $_POST["discounts"]; $sizeof_arr = sizeof($discounts); if ( sizeof_arr >0 ) { } else { } Does not work, get this error Notice: Use of undefined constant sizeof_arr - assumed 'sizeof_arr' in \\nas44ent\domains\l\languageschoolsuk.com\user\htdocs\admin\add_course_form_submit.php on line 22 Thanks in advance You forgot your $ in front of your variable: $discounts = $_POST["discounts"]; $sizeof_arr = sizeof($discounts); if ( $sizeof_arr >0 ) // <--- Right here { } else { } Link to comment https://forums.phpfreaks.com/topic/197018-size-of-array/#findComment-1034262 Share on other sites More sharing options...
deansaddigh Posted March 30, 2010 Author Share Posted March 30, 2010 Hahaha wow i feel stupid!! Thanks Link to comment https://forums.phpfreaks.com/topic/197018-size-of-array/#findComment-1034266 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.