codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php $string = "Topher:Topher1234@mac.com\nElvis:elvispresley@gmail.com\nMarilyn:marilyn.monroe@hotmail.com"; $string = explode("\n", $string); $result = array(); # or your existing array foreach($string as $chunk){ $to_array = new stdClass(); $to_array->id = null; $to_array->surname = null; list($to_array->name, $to_array->email) = explode(':', $chunk); $result[] = $to_array; } print_r($result);
Private
[
?
]
Run code
Submit