hi all,
Can you please tell me how do I turn an array into a string?
Thanks
hi all,
Can you please tell me how do I turn an array into a string?
Thanks
Last edited by Twey; 02-11-2009 at 12:03 PM. Reason: Signature.
PHP not like C/C++
String in PHP doesn't consist of array of char like C
Using implode().
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
This is the example :
Yeah, good idea.<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo $comma_separated; // lastname,email,phone
?>
Btw, what is the diffrence between explode and strtok?
Thanks
Quite a lot.
Code:$str = "foo\nbar\tbaz\n\tquux"; explode("\n\t", $str); // array("foo\nbar\tbaz", 'quux'); strtok($str, "\n\t"); // 'foo' strtok("\n\t"); // 'bar' strtok("\n\t"); // 'baz' strtok("\n\t"); // 'quux' strtok("\n\t"); // false
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
nice...
thanks, I've learnt from you
Bookmarks