Lately what I've wanted to do is read specific text after a specific character. What I want to do is read the numbers after an equal sign. This is the text that I have:
Lime Green = 13,
Sensei Gray = 14,
Aqua = 15,
Arctic White = 16,
Black Sunglasses = 101,
Dark Vision Goggles = 102,
The numbers that are after the "=" sign is the ID for the text. What I want to do is grab the ID for the text an place it in the variable $id, any help would be highly appreciated!
Use explode:
$parts = explode(' = ', rtrim($line, ','));
Then $parts[0]
will be the phrase and $parts[1]
will be the ID.
Use regular expression for this
$content="Lime Green = 13,
Sensei Gray = 14,
Aqua = 15,
Arctic White = 16,
Black Sunglasses = 101,
Dark Vision Goggles = 102,";
preg_match_all("/=(.*),/siU",$content,$output);
print_r($output[1]);