$a = ' 1=a # 2=b # 3=c # 4=d '; $alist = explode (' # ', $a), foreach ($alist as $key + = $value) {$arr =explode (' = ', $value); $blist [$arr [0]]= $arr [1];echo] $blist [$key] ";}
echo "$blist [$key]"; Only output ABC is missing the last one each time how to output ABCD
Reply to discussion (solution)
Direct echo $arr [1]; No, it's okay.
Be sure to use $blist output words should be written as echo "$blist [$key +1]"; Because your $blist array index is starting from 1 to 4
Oh, wrong, it should be echo $blist [$key +1];
Key is 0-3
and $arr[0] is 1-4
So different, change it to this.
$a = ' 1=a # 2=b # 3=c # 4=d '; $alist = explode (' # ', $a), foreach ($alist as $key + = $value) { $arr =explode (' = ', $value); c1/> $blist [$arr [0]-1]= $arr [1]; echo "$blist [$key]";}
$arr [1] can actually output ABCD to solve this problem.
So how do you write the output C? $arr [1[3]]? It seems wrong.
Key is 0-3
and $arr[0] is 1-4
So different, change it to this.
$a = ' 1=a # 2=b # 3=c # 4=d '; $alist = explode (' # ', $a), foreach ($alist as $key + = $value) { $arr =explode (' = ', $value); c4/> $blist [$arr [0]-1]= $arr [1]; echo "$blist [$key]";}
$arr [1] can actually output ABCD to solve this problem.
So how do you write the output C? $arr [1[3]]? It seems wrong.
Direct echo $arr [1]; No, it's okay.
Be sure to use $blist output words should be written as echo "$blist [$key +1]"; Because your $blist array index is starting from 1 to 4
$arr [1] can actually output ABCD to solve this problem.
So how do you write the output C? $arr [1[3]]? It seems wrong.
That is, outputting a single data
Echo $blist [3]; C
Notice the difference between the associative array and the subscript array
$arr [1] can actually output ABCD to solve this problem.
So how do you write the output C? $arr [1[3]]? It seems wrong.
Key is 0-3
and $arr[0] is 1-4
So different, change it to this.
$a = ' 1=a # 2=b # 3=c # 4=d '; $alist = explode (' # ', $a), foreach ($alist as $key + = $value) { $arr =explode (' = ', $value); c1/> $blist [$arr [0]-1]= $arr [1]; echo "$blist [$key]";}
$arr [1] can actually output ABCD to solve this problem.
So how do you write the output C? $arr [1[3]]? It seems wrong.
Echo $blist [2];