str_getcsv示例 [英] str_getcsv example
问题描述
我想将逗号分隔的值字符串解析为数组。我想尝试 str_getcsv()
php功能,但我找不到任何好的例子,如何使用它。
I want to parse a comma separated value string into an array. I want to try the str_getcsv()
php function but I can't find any good examples on how to use it.
例如,我有一个输入,用户提交编程语言(php,js,jquery等)的标签,如stackoverflow中的标签问题。
For example I have an input where users submit tags for programming languages (php, js, jquery, etc), like the "tags" input in stackoverflow when you submit a question.
如何将一个输入与例如 value =php,js,jquery
使用str_getcsv?
How would I turn an input with example value="php, js, jquery"
into an array using str_getcsv?
推荐答案
http://us3.php.net/manual/en/function.str-getcsv.php 不包括标准示例,但用户提交的笔记做一个体面的工作覆盖它。如果这是一个表单输入:
Its true that the spec at http://us3.php.net/manual/en/function.str-getcsv.php doesn't include a standard example, but the user-submitted notes do a decent job of covering it. If this is a form input:
$val = $_POST['value'];
$data = str_getcsv($val);
$ data
值。尝试一下,看看是否有其他问题。
$data
is now an array with the values. Try it and see if you have any other issues.
这篇关于str_getcsv示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!