I have to build an HTML table that shows data for users versus pages visited. It seems klunky to use for and/or foreach loops, but I can’t think of anything better. I’m using PHP, but I would assume that this is language agnostic.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Avoiding loops is probably not possible, if not in implementation, then it will still happen at machine level.
However, if you want to try stay ‘pure’ without nasty code, you can at least do:
At least that way it might be somewhat maintainable. and you don’t have much worry about incomplete strings.
You could also subsitutue some of that code with
Which while being rather concise, will possibly get you in a bit of hot water eventually and it will need recoding. ( and implode internally runs a loop, so its a lose-lose ).
If you don’t mind the over head of extra function calls ( and still running loops ) this could make for more concise code without too many negatives:
But beware, thats hard to read, and you keep that up one day you’ll wake up with lisp.