[英]Split strings and store in array
I have a variable called : $elementname 我有一个变量: $ elementname
The print values using : 打印值使用:
print_r($elementname) is : print_r($ elementname)是:
hardwareaccessIPsdefaultgwinterface_nameinterface_rxinterface_txinterface_error
While, var_dump($elementname) is : 而var_dump($ elementname)是:
string(8) "hardware"
string(6) "access"
string(3) "IPs"
string(9) "defaultgw"
string(14) "interface_name"
string(12) "interface_rx"
string(12) "interface_tx"
string(15) "interface_error"
My question is how may i split this strings and store in an array ? 我的问题是如何分割这些字符串并存储在数组中?
From the print_r, it looks joined with no delimiter :( There must be a way since var_dump was able to split it in the output. 从print_r来看,它看起来像是没有定界符的 :(必须有一种方法,因为var_dump能够在输出中拆分它。
It probably has whitespace character that is not visible to us. 它可能具有我们看不见的空白字符。 try this myarray will have the splitted data like you wanted
尝试此myarray将具有您想要的拆分数据
$myarray = preg_split("[\s]",$elementname)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.