質問

From:

BOBBY,9238123
LOBBY,2312312

Into:

BEGIN:VCARD
VERSION:2.1
N:BOBBY;;;;
FN:BOBBY
TEL;CELL:9238123
END:VCARD

BEGIN:VCARD
VERSION:2.1
N:LOBBY;;;;
FN:LOBBY
TEL;CELL:3423423
END:VCARD

the bobby repeats twice and phone number once This is what I have tried

my code:

foreach(explode("\n", $text) as $line) {
    // I don't know what to do next
}
役に立ちましたか?

解決

You can retrieve the fields of each line using str_getcsv().

http://www.php.net/manual/en/function.str-getcsv.php

Or just explode a second time:

foreach( explode( "\n", $text ) as $line )
{
    $fields = explode( ',', $line );
    var_dump( $fields );
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top