我有以下数组输出:
[38] => x._domainkey 14400 IN TXT ( "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApYA+ELn4SxsERDFgUB9pUnB4PjbcUlSJoLHAlCq1MLVA3NxgLKSAz+lSczyMH97Y/xOpJf1X1LSoGgNh5GVRn0t"
[39] => "pm1QOPfKbNHx8VMNn4L/KZSPGFyySDUK/UPnF1QoMckoU5a/LgtI8x1ttry5oySDTY9KprVAf92uK6pOFQJA3QlzV2P+R4tx/zho5KlDHmc8YKjL7rLjgQVX7GUBi9cHr0+BQdVFgFL8SwBY8fn/CQ"
[40] => "42JMsEWcMjjEkbAwi9yscGQoTih+kctjr4W8LDF28vyJixozbaFpG8pJ+jGDAho+Zjt/XReOZQP0h51Y8md3/x/F0+gST4mn0mCskNtIQIDAQAB" )
我怎样才能在建造之后得到这个?
[38] => x._domainkey 14400 IN TXT ( "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApYA+ELn4SxsERDFgUB9pUnB4PjbcUlSJoLHAlCq1MLVA3NxgLKSAz+lSczyMH97Y/xOpJf1X1LSoGgNh5GVRn0tpm1QOPfKbNHx8VMNn4L/KZSPGFyySDUK/UPnF1QoMckoU5a/LgtI8x1ttry5oySDTY9KprVAf92uK6pOFQJA3QlzV2P+R4tx/zho5KlDHmc8YKjL7rLjgQVX7GUBi9cHr0+BQdVFgFL8SwBY8fn/CQ42JMsEWcMjjEkbAwi9yscGQoTih+kctjr4W8LDF28vyJixozbaFpG8pJ+jGDAho+Zjt/XReOZQP0h51Y8md3/x/F0+gST4mn0mCskNtIQIDAQAB" )
一条规则。
我努力尝试获得多个数组的输出,但不是一条规则:
Array (
[0] => x._domainkey
[1] => 14400
[3] => TXT
[4] => ( "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApYA+ELn4SxsERDFgUB9pUnB4PjbcUlSJoLHAlCq1MLVA3NxgLKSAz+lSczyMH97Y/xOpJf1X1LSoGgNh5GVRn0t"
)
Array (
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] => "pm1QOPfKbNHx8VMNn4L/KZSPGFyySDUK/UPnF1QoMckoU5a/LgtI8x1ttry5oySDTY9KprVAf92uK6pOFQJA3QlzV2P+R4tx/zho5KlDHmc8YKjL7rLjgQVX7GUBi9cHr0+BQdVFgFL8SwBY8fn/CQ"
)
Array (
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] => "42JMsEWcMjjEkbAwi9yscGQoTih+kctjr4W8LDF28vyJixozbaFpG8pJ+jGDAho+Zjt/XReOZQP0h51Y8md3/x/F0+gST4mn0mCskNtIQIDAQAB" )
)
我希望[4]之后的一个规则上的数组[5],这可能吗?
答案 0 :(得分:2)
在进行一些清理(删除引号,括号等)之后,您需要连接元素。在这种特定情况下,我从第一个元素中删除了最后一个字符(要删除尾随引号,也可以是class QuestionFilter(FilterSet):
difficulty_avg__gt = django_filters.NumberFilter(name='difficulty_avg', lookup_expr='gt')
difficulty_avg__lt = django_filters.NumberFilter(name='difficulty_avg', lookup_expr='lt')
class Meta:
model = models.Question
fields = {'difficulty_avg': ['lt', 'gt']}
class QuestionViewSet(ModelViewSet):
queryset = models.Question.objects.annotate(difficulty_avg=Avg('difficulty_questions__difficulty'))
或trim()
),并使用trim()
删除引号和尾随引号在接下来的两个元素上。
如果这三个元素的位置是动态的,首先搜索一个可能对您的用例唯一的值(在我的示例中,我使用trim()
)并使用该键作为连接的基础:< / p>
domainkey
答案 1 :(得分:1)
这不是数组合并,它是字符串连接。
$array[38] .= $array[39] . $array[40]; // combine the 3 lines into one
array_splice($array, 39, 2); // remove the continuation lines
只要行在值之前包含(
,您就需要执行此操作。你必须得到所有的行,直到匹配)
并连接它们。