ChrisWheeler Posted April 25, 2015 Share Posted April 25, 2015 Hi folks. I have something I want to do but don't have the knowledge to do it. I know the bare bones of php but not enough to to right home about. Here's what I would like to do. I am using wordpressand a theme that uses this line of code to get all users information in an array. $questions = ThemexUser::$data['user']['profile']; What I would like to do is get the number of filled in fields and display them. EG: "You have 7 of 11 fields filled out". I have been trying for a week now without any results. Any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/295865-displaying-number-of-answered-questions-in-an-array/ Share on other sites More sharing options...
Barand Posted April 25, 2015 Share Posted April 25, 2015 And we don't have the knowledge of what your $questions variable contains. Post the output from var_export($questions); Link to comment https://forums.phpfreaks.com/topic/295865-displaying-number-of-answered-questions-in-an-array/#findComment-1509955 Share on other sites More sharing options...
ChrisWheeler Posted April 25, 2015 Author Share Posted April 25, 2015 It holds information like name, height, eye colour, smoker, etc. I just want to display the number of filled out fields, and of total fields. Link to comment https://forums.phpfreaks.com/topic/295865-displaying-number-of-answered-questions-in-an-array/#findComment-1509956 Share on other sites More sharing options...
Barand Posted April 25, 2015 Share Posted April 25, 2015 Not very helpful. I'm out. Link to comment https://forums.phpfreaks.com/topic/295865-displaying-number-of-answered-questions-in-an-array/#findComment-1509957 Share on other sites More sharing options...
ChrisWheeler Posted April 26, 2015 Author Share Posted April 26, 2015 Ok, here's what I have so far. $a = 0; $v = count($a); $questions = in_array("$a", ThemexUser::$data['user']['profile'], true); echo $v; So now you can better see what I'm trying to do. This code gives me a "0", however I purposly left 3 questions unanswered so I'm doing something wrong. FYI: The result from "var_export($questions)" is false. Link to comment https://forums.phpfreaks.com/topic/295865-displaying-number-of-answered-questions-in-an-array/#findComment-1509970 Share on other sites More sharing options...
ignace Posted April 26, 2015 Share Posted April 26, 2015 Barand asked you to do this: $questions = ThemexUser::$data['user']['profile']; var_export($questions);And put the output here. Link to comment https://forums.phpfreaks.com/topic/295865-displaying-number-of-answered-questions-in-an-array/#findComment-1509978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.