Search code examples
phparraysimplode

How to implode array data from index 2


I have array data like this :

$word[0]="search";
$word[1]="journal";
$word[2]="information";
$word[3]="system";

If I make PHP code like this :

$output=implode(" ",$word);

The output (implode result) is a combination of word ("search journal information system"). If I want to implode from index 2 so the result="information system". How the solution this problem?


Solution

  • Please try,

    echo join(' ', array_slice($word, 2, 2));

    // information system