开发者

How to explode this into an array of variables?

I already have the following in place to explode the br's in $tmp..

  $tmp = explode('<br>', $tmp);
  echo $tmp[0];
  echo "<br>";
  echo $tmp[1];

Now, in $tmp[0] there is a bunch of text, separated by a pipeline "|". ie: word1|word2|word3|word4|word5 take notice, the last once doesn't end in a pipeline..

How can I 开发者_JAVA技巧explode $tmp[0] to grab each bit of text, turn them into an array, ie: $pipetxt[0], $pipetxt[1], etc. without the pipelines..

Can I do the exact same as the above, after the above occurs.. but go;

$pipetxt = explode('|', $tmp[0]);
echo $pipetxt[0];
echo "<br>";
echo $pipetxt[1];

Thank you!


Your explode looks good, and you can output all your $pipetxt with foreach():

foreach($pipetxt as $out)
  echo $out . "<br>";


Yes

But you should probably adopt some loops.

$tmp = explode('<br>', $tmp);

foreach($tmp as $pipeline){
 $pipetxt_array = explode('|', $pipeline);
 foreach ($pipetxt_array as $output){
  echo $output."<br />";
 }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜