multi array search value no need exact match - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of multi array search value no need exact match.php
- <?php
- $result =
- array(
- array(
- 0 => 'blue',
- 1 => 'red',
- 2 => 'green string',
- 3 => 'red ',
- 4 => 'Black'
- ),
- array(
- 0 => 'blue one',
- 1 => 'red one',
- 2 => 'green string one',
- 3 => 'Car one',
- 4 => 'Black Car one'
- ),
- array(
- 0 => 'blue two',
- 1 => 'red two',
- 2 => 'green string two',
- 3 => 'two Car ',
- 4 => 'Black Car two'
- )
- );
- $filterBy='Car';
- foreach ($result as $key => $valuea) {
- foreach ($valuea as $value) {
- if (strpos($value, $filterBy) !== false) {
- $new[] = $value;
- }
- }
- }
- echo '<pre>'; print_r(array($new)); echo '</pre>';
File Description
- multi array search value no need exact match
- PHP Code
- 25 Aug-2022
- 566 Bytes
You can Share it:
Latest PHP Pastes