I'm quite new to regular expression which I have trial and error test.
How can I replace:
<input name="token" type="text" id="test" value="">
like it will first search for the id="test" if the id exist it will set a 'variable' in value="" tags.
but if value="" has containing a varianble
ex:
<input name="token" type="text" id="test" value="token" />
it should replace the whole value="token" into a a desired variable.
preg_match('%<[^>]*(id="test"[^>]*>)([^<]*)</[^>]*>%', $html, $match);
which is it only search for HTML tags which has closing tags
ex: <div id="test"></div>
and for the value from 'input tags'. I came up with this solution which is not good.
$data['token'] = 'test';
str_replace(array_keys($data),array_values($data),$html);
can someone help me and give me some tips on regular expression on PHP. thank you.