0
I started recently with programming in PHP and I’m having some difficulty in understanding some functions anyway, I’m participating in a project, and as part of the project I need to store a array
in a arquivo.txt
that I person read later(up to here blz, saved the file with file_input_contents, and used the serialize function so that it is possible to write the array inside a file).
My difficulty is:
1) How do I read the file?
A: duties fopen()
? Blz, how do I go through this file and remove only one string
, exactly one PK
of that file?
$conteudo = serialize($array);
$caminho ='';
file_put_contents($caminho, $conteudo);
Content of array barring:
a:1:{s:5:"items";a:1:{i:0;a:1:{s:2:"pk";i:1338838365890273563;}}}
I don’t know if it’s clear, but I want to get the code after i: which would be 13388385890273563. Vlw!!!!
– Felippe Longo
you get exactly that
a:1:{s:5:"items";a:1:{i:0;a:1:{s:2:"pk";i:1338838365890273563;}}}
?– novic
Voce can use the file_get_contents to read the file and unserialize for the text to be array again
– Icaro Martins
Do exactly the reverse so that using file get Contents and then unserialize, will have an array with the same data as before... (Sorry, I’m on mobile and can’t post as a decent response)
– Jader A. Wagner