-1

hello , i have value 1284&kec=220107&prop=220000

here i want to take the numbers in front & the numbers in front are not always three letters, sometimes two letters and sometimes also one, how to remove or delete values ​​after &

example : 1284&kec=220107&prop=220000
result value = 1284

example : 11&kec=2332&prop=563454
result value = 11

can you give an example?

Harry Wardana
  • 277
  • 1
  • 5
  • 15

1 Answers1

0

You can use explode() to convert the string to an array and then get what you want. Like so -

$example = '1284&kec=220107&prop=220000';
$ex = explode("&kec", $example); // convert it to array where $kec is found
$value = $ex[0]; // output: 1284 // the first key will hold the value before $kec

$example2 ='11&kec=2332&prop=563454';
$ex = explode("&kec", $example2);
$value = $ex[0]; // output: 11
sauhardnc
  • 1,961
  • 2
  • 6
  • 16