Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Getting info from string


Marked - 9:54 am on Feb 8, 2010 (gmt 0)


Hi all,

I am trying to write something that displays the most voted on choice from a poll.

In the database, all the choices, options etc. for the poll are stored in a single string.. so im not sure how i can get the info I want, but im sure there are some php functions which can do the trick.

Here's an example of one:
a:1:{i:1;a:3:{s:8:"question";s:27:"Will you switch
over to
VX?";s:6:"choice";a:3:{i:1;s:3:"Yes";i:2;s:2:"No";
i:3;s:17:"I'll use
both";}s:5:"votes";a:3:{i:1;i:5;i:2;i:7;i:3;i:12;}
}}

What I need to do with this string is get the 'choice'(as a string, e.g.: 'Yes','No','I
ll use) that has the highest number of votes.

In the above the string, here are choices: votes :
Yes : 5
No : 7
I'll use both : 12

So basically what I'm looking to do is return 'I'll use both' from the string, because it has he most votes.

Thanks in advance.


Thread source:: http://www.webmasterworld.com/php/4076208.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com