Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wera-as authored Nov 22, 2023
1 parent 97eb835 commit 36980bb
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# HTTP Query Builder

The HTTP Query Builder is a simple, but efficient PHP function that takes an associative array and returns a URL encoded HTTP query string. The function validates the input data and returns an error message if the input is not an array. It's compatible with PHP 5.6 and onwards.
# HTTP Query Builder ![GitHub](https://img.shields.io/badge/version-v1.2.0-blue)
The HTTP Query Builder is a sophisticated PHP function that constructs a URL-encoded HTTP query string from an associative array. This function now supports nested arrays, custom delimiter options, and the ability to preserve numeric indexes in array keys. It validates the input data and returns an error message if the input is not an array. Compatible with PHP 5.6 and onwards.

## Features

- Takes an associative array and converts it into a URL encoded HTTP query string.
- Checks if the input data is an array.
- If the input is not an array, it returns an error message.
- Supports PHP 5.6 and onwards.
- Converts an associative array, including nested arrays, into a URL-encoded HTTP query string.
- Custom delimiter option for query strings.
- Ability to preserve numeric indexes in array keys.
- Enhanced input validation with detailed error reporting.
- Fully compatible with PHP 5.6 and later versions.

## Requirements

- PHP 5.6 or higher.

## Installation

To use the HTTP Query Builder, simply include it in your PHP project:
To use the HTTP Query Builder, include it in your PHP project:

```php
include_once 'build_http_query_from_array.php';
Expand All @@ -27,9 +27,15 @@ First, prepare an associative array that needs to be converted into a URL encode

```php
$data = [
'name' => 'John',
'age' => 30,
'city' => 'New York',
'user' => [
'name' => 'John',
'details' => [
'age' => 30,
'city' => 'New York'
]
],
'preferences' => ['movies', 'books'],
'newsletter' => true
];
```

Expand All @@ -45,16 +51,17 @@ if ($result['error']) {
}
```

In this example, the function is called with an associative array as an argument. The returned query string is then printed. If there is an error, it will print the error message instead.
In this example, the function takes a complex associative array and outputs a URL-encoded query string. If an error occurs, it prints an error message.

## Errors and Exceptions

The function will return an associative array with an 'error' flag. If there was no error during the function execution, 'error' will be `false` and 'query' will contain the constructed query string. If there was an error, 'error' will be `true` and 'message' will contain a string with an error message.
The function returns an associative array with an 'error' flag. If no error occurs during execution, 'error' is false, and 'query' contains the constructed query string. In case of an error, 'error' is true, and 'message' contains an error description.

## Contributing

Contributions are welcome! Please feel free to fork this project and submit your enhancements via a pull request.
Contributions to enhance functionality or documentation are welcome! Please fork this project and submit your contributions via pull requests.

## License

The HTTP Query Builder is open-source software licensed under the GNU license.
The HTTP Query Builder is open-source software, licensed under the GNU license.
![License](https://img.shields.io/github/license/wera-as/http-query-builder)

0 comments on commit 36980bb

Please sign in to comment.