Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Post name wildcard - $_POST['var_'.*];

Tags:

php

Is there some kind of wildcard I can use to create POST vars that start with a specific string?

Essentially, I am trying to capture any POST that contains bSortable_(wildcard) as the name.

bSortable_1 bSortable_2 bSortable_3

I am doing this for a library jquery datatables.

http://www.datatables.net/usage/server-side

like image 613
Peter Avatar asked Dec 28 '22 01:12

Peter


1 Answers

Get post variables to an array, than iterate through it while you filter.

foreach($_POST as $key => $value) {
  $pos = strpos($key , "bSortable_");
  if ($pos === 0){
    // do something with $value
  }
}
like image 93
SadullahCeran Avatar answered Jan 08 '23 17:01

SadullahCeran