Home › Forums › Back End › case issue › Reply To: case issue
April 29, 2014 at 7:04 pm
#168899
__
Participant
$social
, as you explained, is an array. It will never match a string (which is what "facebook"
, "twitter"
, etc. are).
I don’t know your specific requirements, but it seems you only need to know which of your calls to ot_get_option
returned true
. Is this correct? If so,
<?php
function findSocial(){
// list of social site names
$social = array( "facebook","twitter","vimeo" /* etc. */ );
// loop through each
foreach( $social as $site ){
// if ot_get_option matches, return that site name
if( ot_get_option( $site ) ){
return "this is $site";
}
}
// no matches
return false;
}
Usage:
echo findSocial();
/* prints something like:
this is css-tricks
*/
You could also pass $social
as a function parameter, which would make it much easier to add or remove names from the list.