I have an array in开发者_高级运维 $_POST:
Array ( [tags] => Javascript,PHP,Java,C++,Python)
How can i convert this Array into Array like this:
Array ( [tag1] => Javascript [tag2] => PHP [tag3] => Java [tag4] => C++ [tag5] => Python)
I guess i need to use regexp to remove the commas and do split in "foreach as".. But i'm so newbie in PHP... Please help me
$tags = explode(",", $_POST['tags']);
print_r($tags);
Outputs
Array ( [0] => Javascript [1] => PHP [2] => Java [3] => C++ [4] => Python )
For a string with comma, you can split it using explode
$new_array = explode(',', $_POST['tags']);
Then you can use the $new_array
for your process.
精彩评论