<?php
$torrent = 'd8:announce37:http://blender.waag.org:6969/announce13:creation datei1212070099e4:infod6:lengthi196898674e4:name30:big_buck_bunny_720p_stereo.ogg12:piece lengthi262144e6:pieces15040:DñÀsÑ45/';
$regex = "/lengthi([0-9]+)e/i";
$sizes = array();
preg_replace_callback($regex, function($matches) use(&$sizes)
{
$sizes[] = substr($matches[2], 0, $matches[1]);
}, $torrent);
var_dump($sizes); // I want to get "262144", you can see this just before "pieces", top right
Warning: Undefined array key 2 in /in/KGSd6 on line 12
Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /in/KGSd6 on line 12
Warning: Undefined array key 2 in /in/KGSd6 on line 12
Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /in/KGSd6 on line 12
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
Output for 8.0.0 - 8.0.30
Warning: Undefined array key 2 in /in/KGSd6 on line 12
Warning: Undefined array key 2 in /in/KGSd6 on line 12
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
Notice: Undefined offset: 2 in /in/KGSd6 on line 12
Notice: Undefined offset: 2 in /in/KGSd6 on line 12
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
Notice: Undefined offset: 2 in /in/KGSd6 on line 12
Notice: Undefined offset: 2 in /in/KGSd6 on line 12
array(2) {
[0]=>
bool(false)
[1]=>
bool(false)
}