allegro / php-protobuf

PHP Protobuf - Google's Protocol Buffers for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how can i delete item with repeated field

muyilangjun opened this issue · comments

how can i delete item with repeated field

There is no direct support to remove a repeated field item. What you can do is:

.proto file

message Test
{
    repeated string values = 1;
}

PHP snippet

$message = new TestMessage();
$values = $message->getValues();
unset($values[1]); // remove second item
$message->clearValues();
for ($values as $value) {
    $message->appendValues($value);
}