Array ( [0] =>
Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com
[1] =>
Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com
[2] =>
Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com
[3] =>
Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com
[4] =>
___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com
[5] =>
Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com
)
需要在数组索引中找到___1nam
并获取下一个单词(Mr Muruganandam)
。并推入一个新阵列。
以不同的方式尝试没有运气
提前致谢。
答案 0 :(得分:0)
如果可能,您应该首先正确构建阵列,因为您希望使用它。
虽然看起来大致统一,但你可以用可解析的版本切换你的分隔符(各种各样),然后使用parse_str(),在循环中通过引用传递来更新原始文件。
<?php
$data = [
'Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com',
'Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com',
'Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com',
'Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com',
'___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com',
'Enquiry for *S R Air Ticketing & Money Exchange (T Nagar, Chennai)* User Muruganandam enquired for your business related category at Justdial Feedback Details ___1nam Mr Muruganandam Caller Requirement: Domestic Air Ticketing Agents Call Date & Time: Thu, 26 Apr 2018 13:54:31 ___ph +919080842161 ___1em nmsmurugan2000@gmail.com'
];
foreach ($data as &$value) {
// escape &'s
$value = str_replace('&', '%26', $value);
// replace separators with parsable keys (*verbose as you could use an array)
$value = str_replace('Enquiry for ', 'enquiry=', $value);
$value = str_replace(' User ', '&user=', $value);
$value = str_replace(' enquired for ', '&subject=', $value);
$value = str_replace('Feedback Details ___1nam', '___1nam', $value);
$value = str_replace('___1nam', '&details[name]=', $value);
$value = str_replace('Caller Requirement: ', '&details[caller]=', $value);
$value = str_replace(' Agents Call Date %26 Time: ', '&details[date]=', $value);
$value = str_replace(' ___ph ', '&details[phone]=', $value);
$value = str_replace(' ___1em ', '&details[email]=', $value);
parse_str($value, $value);
}
print_r($data);
然后您可以像$data[0]['details']['name']
一样访问它。
<强>结果强>
Array
(
[0] => Array
(
[enquiry] => *S R Air Ticketing & Money Exchange (T Nagar, Chennai)*
[user] => Muruganandam
[subject] => your business related category at Justdial
[details] => Array
(
[name] => Mr Muruganandam
[caller] => Domestic Air Ticketing
[date] => Thu, 26 Apr 2018 13:54:31
[phone] => 919080842161
[email] => nmsmurugan2000@gmail.com
)
)
[1] => Array
(
[enquiry] => *S R Air Ticketing & Money Exchange (T Nagar, Chennai)*
[user] => Muruganandam
[subject] => your business related category at Justdial
[details] => Array
(
[name] => Mr Muruganandam
[caller] => Domestic Air Ticketing
[date] => Thu, 26 Apr 2018 13:54:31
[phone] => 919080842161
[email] => nmsmurugan2000@gmail.com
)
)
[2] => Array
(
[enquiry] => *S R Air Ticketing & Money Exchange (T Nagar, Chennai)*
[user] => Muruganandam
[subject] => your business related category at Justdial
[details] => Array
(
[name] => Mr Muruganandam
[caller] => Domestic Air Ticketing
[date] => Thu, 26 Apr 2018 13:54:31
[phone] => 919080842161
[email] => nmsmurugan2000@gmail.com
)
)
[3] => Array
(
[enquiry] => *S R Air Ticketing & Money Exchange (T Nagar, Chennai)*
[user] => Muruganandam
[subject] => your business related category at Justdial
[details] => Array
(
[name] => Mr Muruganandam
[caller] => Domestic Air Ticketing
[date] => Thu, 26 Apr 2018 13:54:31
[phone] => 919080842161
[email] => nmsmurugan2000@gmail.com
)
)
[4] => Array
(
[details] => Array
(
[name] => Mr Muruganandam
[caller] => Domestic Air Ticketing
[date] => Thu, 26 Apr 2018 13:54:31
[phone] => 919080842161
[email] => nmsmurugan2000@gmail.com
)
)
[5] => Array
(
[enquiry] => *S R Air Ticketing & Money Exchange (T Nagar, Chennai)*
[user] => Muruganandam
[subject] => your business related category at Justdial
[details] => Array
(
[name] => Mr Muruganandam
[caller] => Domestic Air Ticketing
[date] => Thu, 26 Apr 2018 13:54:31
[phone] => 919080842161
[email] => nmsmurugan2000@gmail.com
)
)
)