如何在PHP中过滤此字符串?

时间:2016-06-02 16:53:30

标签: php filter

如何过滤PHP中字符串2968的数字a:1:{i:0;s:4:"2968";}

号码2968可以是其他号码,因此请将其从00000过滤到99999

1 个答案:

答案 0 :(得分:1)

此字符串是serialized数组。你应该unserialize然后迭代数组或访问你需要的已知索引:

% Labels for the columns
header = sprintf('%s\t', 'Feature', 'F-score', 'Precision', 'Recall');

% Store your data within a cell array
data = {'Feature1', 0.81, 0.82, 0.83, 0.84, 0.85, 0.86;
    'Feature2', 0.87, 0.88, 0.83, 0.84, 0.85, 0.86}.';

% Construct your tab-delimited string with newlines between rows
datastring = sprintf('%s\t%0.2f (%0.2f)\t%0.2f (%0.2f)\t%0.2f (%0.2f)\n', data{:});

% Append the header to the rest of the data
fullstring = sprintf('%s\n%s', header, datastring);

% Copy this string to the system clipboard
clipboard('copy', fullstring);