I'm trying to split a string by the first occurrence of an equals sign (=). Some how it keeps splitting at all of them. I just need the split at the first.

This is the code:

$value = 'setting1=width="100%" cellpadding="2" cellspacing="0" border="0" ';
$find = preg_split("/=/", $value, -1);
print_r($find);

I just want it split in two (2) parts: /setting1/ and /width="100%" cellpadding="2" cellspacing="0" border="0" /.

What am I doing wrong?

Comments

Avaya’s picture

I always do this.... I post or ask a question and then figure it out minutes later....

$find = preg_split("/=/", $value, 2);

Sorry for wasting these fine Drupal resources on my incompetencies.

lancsDavid’s picture

posting a question & then answering it yourself....

u doofus

WorldFallz’s picture

hmm.... who's the doofus?

Someone who follows up their post with the solution for the benefit of future users or someone who comments on an 8 month old thread just to call them a doofus? ;-0~