I am using AJAX to retrieve the ID of a certain HTML element. The HTML ID is constructed like "sqlitem_1", "sqlitem_2", "sqlitem_3" etc. and each number corresponds to a record in the database.
I tried preg_replace('/\D/', '', $item);where $item is the string I need to cut, but this didn't do the trick.
$item = $_GET['item']; preg_replace('/\D/', '', $item); // Haal alle non-nummeristic characters uit de string $item. echo json_encode($item);preg_replacedoesn't change the original value but rather returns the new one. You might wanna check preg_replace. So you should do$item = preg_replace('/\D/', '', $item);instead.