8
How can I make a explode
in a variable where I can then access it through nominal index, and nay for numerical index?
Follow the example to be clearer:
<?php
// Aqui acesso pelo índice
$user = "Diego:25:RJ";
$info = explode(":",$user);
echo "O nome é ".$info[0];
?>
Instead of using:
echo "O nome é ".$info[0];
I would like to use:
echo "O nome é ".$info["nome"];
In my real example, I would solve a certain situation where the insertion or removal of certain information could be bad in a use with the use of numerical index.
it’s funny, I try to understand why the question was negative. I think it was more by a taste criterion than by the policy of the site.
– DiChrist
I confess that I also did not understand why, it seems to me a valid question, trying to simplify a process, although there is no built-in
explode()
. I already spent my vows today, otherwise I’d give +1– Miguel
@Dichrist If you want to put the values in variables, da to do so: http://ideone.com/OV9QMs
– stderr
@stderr I think this solution is very good too, I should put it as an answer. taking into account that is exactly this (facilitate the process) that the AP seems to want
– Miguel