0

iam not sure: is this the fastest way to check an array for an Value beginning with XXX ? And if yes, extract the value after XXX: ?

foreach ($result['tag'] as $value) {

        $pos = strpos($value, 'xxx:');

        if ($pos !== false) {
            $split = explode('xxx:', $value);
            $r = $split[1];
        } else {
            $r = '';
        }
 }
0

1 Answer 1

1

need to check substr vs explode performance !

by replace 2 lines

$split = explode('xxx:', $value);
$r = $split[1];

with

$r = substr($value,4);

i think the second is more elegant

1
  • 0,5 Seconds faster :-) Thanks Jan 19, 2011 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.