Export an item’s data
Function Definition
public function export ( $fields = null, $id = null, $format = null )
Source File: /pods/classes/Pods.php
Since: 2.0
Parameters
PARAMETER | TYPE | DETAILS |
---|---|---|
$fields | (array) | (optional) Fields to export |
$id | (int) | (optional) ID of the pod item to export |
$format | (string) | You can specify “json” to return a json encoded representation |
Returns
(array|bool) Data array of the exported pod item
Examples
Example 1
<?php $person = pods( 'people', 'fred-flinstone' ); $all_fields = $person->export(); if ( !empty( $all_fields ) ) { foreach( $all_fields as $field => $value ) { // You can use pods_serial_comma to output values, // even if it's an array ?> <h2><?php echo $person->fields[ $field ][ 'label' ]; ?></h2> <p>Value: <?php echo pods_serial_comma( $value, $field, $person->fields ); ?></p> <br /> <?php } } else echo '<strong>No data found.</strong>';
The above example will output:
<h2>Favorite Color</h2> <p>Value: Blue</p> <br /> <h2>Related User</h2> <p>Value: fred_flintstone</p> <br />