Peter Knight Posted November 22, 2018 Share Posted November 22, 2018 Hi I have a page reference field which are a series of checkboxes in the back end Web Design Web Development Marketing Administration In my template I was previously listing only 1 key skill at a time but now I need to output each checked item separated by a comma IE Marketing, Administration This does work but echoes Marketing, Administration, foreach ($staff->skills as $item){ echo "{$item->title},";} How would I keep the comma from appearing at the end of the last item? Thanks Link to comment Share on other sites More sharing options...
kongondo Posted November 22, 2018 Share Posted November 22, 2018 echo $staff->skills->implode(',' 'title'); http://processwire.com/api/ref/wire-array/implode/ 5 Link to comment Share on other sites More sharing options...
LostKobrakai Posted November 22, 2018 Share Posted November 22, 2018 Or if you need to be more sophisticated (and/or multi-language) something like: https://punic.github.io/#Misc-class 1 Link to comment Share on other sites More sharing options...
Peter Knight Posted November 22, 2018 Author Share Posted November 22, 2018 Thanks guys. I actually realized I’d asked this before. Sorry about the duplicate post. Link to comment Share on other sites More sharing options...
adrian Posted November 22, 2018 Share Posted November 22, 2018 @kongondo's approach is definitely the best for PW, but just for extra info in case you ever need to do this with a standard PHP array, you can simply do: The ugly way is rarely useful, but I suppose there might be more flexibility depending on your needs. 2 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now