https://github.com/codewithmark/php-data-parsing-functions
https://github.com/codewithmark/php-data-parsing-functions
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/codewithmark/php-data-parsing-functions
- Owner: codewithmark
- Created: 2017-05-26T15:56:13.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-26T17:01:22.000Z (about 9 years ago)
- Last Synced: 2025-06-14T05:33:27.411Z (12 months ago)
- Language: PHP
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PHP Data Parsing Functions
You can use the below functions for parsing your php data
## Size
Get the length of an array or string
**Size of a string**
$d1 = size('codewithmark');
echo "size of : codewithmark > " . $d1;
//out put
size of : codewithmark > 12
echo "size of : 123 > " . size(123);
//out put
size of : 123 > 3
**Size of an array**
This will count the total number of objects in an array
$a1 = array('term_id' => 5, 'taxonomy' => 'category', 'count' => 3);
echo "size > " .size( $a1);
//out put
size > 3
This will be useful to determine if your result query has any records or not
## Find
From a list of array find an array with particular object
//data array
$a1 =
Array(
Array
(
'term_taxonomy_id' => 5,
'term_id' => 5,
'taxonomy' => 'tumblog',
'description' => '',
'parent' => 0,
'count' => 0,
),
Array
(
'term_taxonomy_id' => 1,
'term_id' => 1,
'taxonomy' => 'category',
'description' => '',
'parent' => 0,
'count' => 2,
),
Array
(
'term_taxonomy_id' => 3,
'term_id' => 3,
'taxonomy' => 'category',
'description' => '',
'parent' => 0,
'count' => 0,
),
Array
(
'term_taxonomy_id' => 4,
'term_id' => 4,
'taxonomy' => 'category',
'description' => '',
'parent' => 0,
'count' => 2,
),
Array
(
'term_taxonomy_id' => 2,
'term_id' => 2,
'taxonomy' => 'nav_menu',
'description' => '',
'parent' => 0,
'count' => 3,
)
);
$d3 = find ($a1, array('term_id' => 5));
print_r($d3);
//out put
(
[0] => Array
(
[term_taxonomy_id] => 5
[term_id] => 5
[taxonomy] => tumblog
[description] =>
[parent] => 0
[count] => 0
)
)
Search for multiple differert objects
$f1 = array('term_id' => 5, 'taxonomy' => 'category', 'count' => 3);
//$a1 is being called from above
$d3 = find ($a1, $f1);
print_r($d3);
//out put
(
[0] => Array
(
[term_taxonomy_id] => 5
[term_id] => 5
[taxonomy] => tumblog
[description] =>
[parent] => 0
[count] => 0
)
[1] => Array
(
[term_taxonomy_id] => 1
[term_id] => 1
[taxonomy] => category
[description] =>
[parent] => 0
[count] => 2
)
[2] => Array
(
[term_taxonomy_id] => 3
[term_id] => 3
[taxonomy] => category
[description] =>
[parent] => 0
[count] => 0
)
[3] => Array
(
[term_taxonomy_id] => 4
[term_id] => 4
[taxonomy] => category
[description] =>
[parent] => 0
[count] => 2
)
[4] => Array
(
[term_taxonomy_id] => 2
[term_id] => 2
[taxonomy] => nav_menu
[description] =>
[parent] => 0
[count] => 3
)
)