I would like to separate a string in PHP and get specific data

Asked

Viewed 23 times

1

I’m making a view taking data from a txt file but the function is returning the whole row and I just want the column. There would be a way to bring only the specific column.

public function carregarPA($arq,$linha){
    $arquivo = file($arq);
    $y = $linha - 1;
    return $arquivo[$y];
}

In the template the return is as follows:

67 0 0 0 0 0 0 82 0 68 12 0 0 2 . 00

I only want the number "82". I’ve tried with the explode() but it didn’t work.

1 answer

0


Use the replace

Example

substr($arquivo[$y],17,2)
  • It worked, thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.