Skip to content

Conversation

@dixy
Copy link
Contributor

@dixy dixy commented Oct 4, 2011

This function is the same as the implode() function, but you can change the string between the last and last-1 elements.

<?php
$arr = array('apple', 'banana', 'kiwi');
echo array_to_str($arr, ', ', ' and'); //returns "apple, banana and kiwi"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function array_to_str($array = array(), $sep = ', ', $sep_last = '')

You can set default empty array.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would probably be preferable.

@chrisberthe
Copy link
Contributor

What's the point of having $return = '';?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete $return variable?

@appleboy
Copy link
Contributor

@chrisberthe I think he forgot to delete it.

@dixy
Copy link
Contributor Author

dixy commented Oct 13, 2011

Yes, I forgot to remove it

@kylefarris
Copy link
Contributor

I like this idea. It would actually be quite useful! Thanks for the pull request.

@narfbg
Copy link
Contributor

narfbg commented Oct 8, 2012

This is way too outdated and is achieveable via 2 lines of code anyway. Please resubmit it based on the latest develop if you still want it.

@narfbg narfbg closed this Oct 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants