arrays - Simplify a php function whitch use FileMaker API -
i use filemaker api php take filemaker data in php. so, works well. simplify it.
/** code correct , can't modify ***/ require_once ('inc/fm/filemaker.php'); require_once ('inc/fm/param_fm.php'); $modele="mura"; $id_folder=$_get["folder"]; $id_ouvrage=$_get["id"]; $findcommand =& $base->newfindcommand($modele); $findcommand ->addfindcriterion('id ouvrage', $id_ouvrage); $result = $findcommand->execute(); if (!filemaker::iserror($result)) { $records = $result->getrecords(); } else{ echo "no result"; } /*** end unmodify code ***/ when want show data use :
$collection = $records[0]->getfield('collection book'); $title = $records[0]->getfield('title book'); $years = $records[0]->getfield('years book'); but have data in array.
$data= array('collection' => 'collection book','title' => 'title book', 'years' => 'years book'); i have 48 datas this. can use array simplify data? help.
i'm not quite sure if it's you're asking for, , doesn't make sense if have 3 fields, this:
foreach ( $data $var => $field ) { $$var = $records[0]->getfield( $field ); } this create variable each of keys have in array. $data provided, create $collection set 'collection book', $title set 'title book' , $years set 'years book'. note capitalization of variable names because 2 of keys in array capitalized.
Comments
Post a Comment