0
I have the following line in the txt file
#EXTINF:-1 tvg-id="Globorj.br" tvg-name="GLOBO RJ HD" tvg-logo="https://2.bp.blogspot.com/-
this line repeats over and over again.
i need to open the txt and exchange the word tvg-name
for NOME
I tried that:
$handler = fopen ( 'uploads/' . $new_name , 'r' ) ;
$nova_palavra = str_replace("tvg-name", "NOME", $handler);
but it didn’t work...
To use with the
str_replace
, utilizefile_get_contents
instead offopen
.– Valdeir Psr
the return of $Handler is coming in what way?
– Diego Braga
@Diegobraga When you use the function
fopen
, the variable returns aresource
. In this case you cannot use with thestr_replace
(that expects a string). In his case, only with thefile_get_contents
;file
andimplode
; orfopen
+fread
.– Valdeir Psr
my full code
$handler = file_get_contents ( 'uploads/' . $new_name , 'r' ) ;
 $nova_palavra = str_replace("tvg-name", "NOME", $handler);
 if ( $handler !== false ) {
 $i = 0 ; 
 $dados = array ( ) ;
 while ( ! feof ( $handler ) ) {
 $linha = fgets ( $handler ) ;
 $info = explode ( ';', $linha ) ;
 $dados [ $i ] [ 'Excluir' ] = $info [ 0 ] ;
 $dados [ $i ] [ 'Nome' ] = trim ( $info [ 1 ] ) ;
 $dados [ $i ] [ 'Link' ] = trim ( $info [ 2 ] ) ;
 ++ $i ;
 }fclose ( $handler ) ;print_r ( $dados ) ;
 }
– André Luiz Mardonis