Как пример.
PHP код:
$string = '
501#
A potion made from ground Red Herbs that restores ^000088about 45 HP^000000.
^ffffff_^000000
Weight :^777777 7^000000
#
502#
A potion made from ground Red and Yellow Herbs that restores ^000088about 105 HP^000000.
^ffffff_^000000
Weight :^777777 10^000000
#
';
$lines = explode(PHP_EOL, $string);
$lines = array_map('trim', $lines);
$item = null;
$desc = null;
$items = array();
foreach ($lines as $line) {
if (preg_match('#(^[\d]+)\##', $line, $match)) {
$item = $match[1];
continue;
}
if (preg_match('#^\##', $line)) {
$items[$item] = $desc;
$desc = null;
continue;
}
$desc .= $line;
}
var_dump($items);
Код:
array
501 => string 'A potion made from ground Red Herbs that restores ^000088about 45 HP^000000.^ffffff_^000000Weight :^777777 7^000000' (length=115)
502 => string 'A potion made from ground Red and Yellow Herbs that restores ^000088about 105 HP^000000.^ffffff_^000000Weight :^777777 10^000000' (length=128)