php获取数组中的数据
我有一个下面的变量php获取数组中的数据,php,arrays,string,Php,Arrays,String,我有一个下面的变量 $test="<title>This is 1 test | "best"</title>, <title>This is 2 test | "best"</title>, <title>This is 3 test | "best"</title>, <title>This is 4 test | "best"</title>, <title>This is
$test="<title>This is 1 test | "best"</title>, <title>This is 2 test | "best"</title>, <title>This is 3 test | "best"</title>, <title>This is 4 test | "best"</title>, <title>This is 5 test | "best"</title>";
谢谢和亲切的问候,$test='这是一个测试|“最佳”,这是两个测试|“最佳”,这是三个测试|“最佳”,这是四个测试|“最佳”,这是五个测试|“最佳”;
$test='<title>This is 1 test | "best"</title>, <title>This is 2 test | "best"</title>, <title>This is 3 test | "best"</title>, <title>This is 4 test | "best"</title>, <title>This is 5 test | "best"</title>';
$array = explode(' , ', trim(str_replace(array('"best"', '|'), '', strip_tags($test))));
print_r($array);
$array=explode(','),trim(str_替换('best','124;'),'',strip_标记($test));
打印(数组);
首先,变量
$test
无效,需要对其中的双引号进行转义,或者对值使用单引号
<?php
$test = '<title>This is 1 test | "best"</title>, <title>This is 2 test | "best"</title>, <title>This is 3 test | "best"</title>, <title>This is 4 test | "best"</title>, <title>This is 5 test | "best"</title>';
$test = str_replace(array('<title>', '| "best"</title>'), array('',''), $test);
$array = explode(", ", $test);
print_r($array);
<?php
$test = '<title>This is 1 test | "best"</title>, <title>This is 2 test | "best"</title>, <title>This is 3 test | "best"</title>, <title>This is 4 test | "best"</title>, <title>This is 5 test | "best"</title>';
$test = str_replace(array('<title>', '| "best"</title>'), array('',''), $test);
$array = explode(", ", $test);
print_r($array);