Find multiple occurrences of a pattern, using regular expressions
P粉186017651
P粉186017651 2024-02-26 23:27:41
0
1
3679

I got this string:

if(Condition A==Value A-AND-Condition B==Value B-OR-Condition C==Value C)

I want an array containing:

array(3) {
  [0]=>
  string(...) "conditionA==valueA"
  [1]=>
  string(...) "conditionB==valueB"
  [2]=>
  string(...) "conditionC==valueC"
}

I'm currently using this pattern:

preg_match("/^if\((. )-(. )\)/U", $current_step_data_exploded[0], $if_statements);

But it doesn't satisfy the third condition correctly. Can anyone help me?

P粉186017651
P粉186017651

reply all(1)
P粉139351297
$string = "if(conditionA==valueA-AND-conditionB==valueB-OR-conditionC==valueC)";
$match = preg_match('/^if\((.+)\)$/', $string, $if);
if ($match) {
  $conditions = preg_split('/\-(AND|OR)\-/', $if[1]);
  print_r($conditions);
} else {
  echo "no matches.";
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template