Skip to content

Instantly share code, notes, and snippets.

@Shakil-Shahadat
Last active December 18, 2021 01:43
Show Gist options
  • Save Shakil-Shahadat/457c96accc1b8f46daaa0edde089120c to your computer and use it in GitHub Desktop.
Save Shakil-Shahadat/457c96accc1b8f46daaa0edde089120c to your computer and use it in GitHub Desktop.
Escape an Array in Easiest Way
<?php
// For MySQL
// Escape $_GET elements
foreach ( $_GET as $key => $value )
{
$_GET[ $key ] = $db->escape_string( $_GET[ $key ] );
}
// Escape $_POST elements
foreach ( $_POST as $key => $value )
{
$_POST[ $key ] = $db->escape_string( $_POST[ $key ] );
}
// For SQLite
// Escape $_GET elements
foreach ( $_GET as $key => $value )
{
$_GET[ $key ] = $db->escapeString( $_GET[ $key ] );
}
// Escape $_POST elements
foreach ( $_POST as $key => $value )
{
$_POST[ $key ] = $db->escapeString( $_POST[ $key ] );
}
@Shakil-Shahadat
Copy link
Author

  • Move this to miscellaneous.php.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment