【问题标题】:Convert point to array using php function使用php函数将点转换为数组
【发布时间】:2016-02-18 10:17:25
【问题描述】:

使用 php 函数将点转换为数组:-
示例:

1. i am xxxxxx
2. i have a good happit
3. i am good boy 
我想转换数组,
[0] -> i am xxxxxx
[1] -> i have a good happit
[2] -> i am good boy 
请帮帮我...在此先感谢

【问题讨论】:

  • 你卡在代码的哪一部分?
  • 从 textarea 字段中获取点,我想在 html 的不同位置显示单个点。所以我需要将该点转换为数组。

标签: php split


【解决方案1】:

假设会有你描述的格式。

$str = $textfield_input;
$text_row = explode("\n", $str); //Each row to $text_row
foreach($text_row as $line) {
    $row = explode(".", $line); 
    $array[] = $line[1];
}

var_dump($array);

array(
[0] => i am xxxxxx
[1] => i have a good happit
[2] => i am good boy 
)

【讨论】:

  • 非常感谢 isnisn 。我从您的代码中得到了预期的结果。谢谢 :)。我放弃投票。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-12
  • 1970-01-01
  • 1970-01-01
  • 2015-04-02
  • 1970-01-01
相关资源
最近更新 更多