php无法找到解决方案,需要解决这个php的问题

时间:2014-11-09 17:49:50

标签: php html arrays foreach solution

我有这段代码

<html>
   <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Desarrollo Web</title>
</head>
<body>
<?php
$jugadors_de_lacrosse = array( "Billy Bitter", "Chris Bocklet", "Jeremy Boltus" );
$jugadors_de_pilota_basca = array( "Iñaqui" );
$esports = array();
$esports["Lacrosse"] = $jugadors_de_lacrosse;
$esports["Pilota Basca"] = $jugadors_de_pilota_basca;

foreach( $esports as $esport => $jugadors ) {
    echo "my favorite players of $esport are ";
}
?>
    </body>
</html>

现在我想打印出我最喜欢的$ esport玩家的玩家名字&#34;这里是玩家的名字&#34;我和另一个foreach有关。

2 个答案:

答案 0 :(得分:1)

这是一个选项:

echo "my favorite players of $esport are ". implode(',',$jugadors);

答案 1 :(得分:1)

或者

echo "My favourite players are ";
foreach($esports as $jugadors) {
  echo $jugadors;
}