• Resolved brunofilipevf

    (@brunofilipevf)


    Good evening, I’m doing a function for values ??resgar a video on vimeo! The lower part of the following function:

    function wp_vimeo($post){
    	sscanf(parse_url($post->post_content, PHP_URL_PATH), '/%d', $vimeo_id);
    	$vimeo = unserialize(file_get_contents("https://vimeo.com/api/v2/video/$vimeo_id.php"));
    }

    So far so good, he is ready to rescue values??! But the function is to capture the TIME and the video THUMBNAIL. I will use then:

    date("i:s",intval($vimeo[0]['duration']));
    $vimeo[0]['thumbnail_large'];

    My problem is this, how to make the function call and opt to choose if I want to rescue THUMBNAIL or TIME?

    Note: I got doing a function for each option, but I want to save a line of code while learning!

    I am grateful!

Viewing 1 replies (of 1 total)
  • Thread Starter brunofilipevf

    (@brunofilipevf)

    function wp_vimeo($post, $show = ''){
    	sscanf(parse_url($post->post_content, PHP_URL_PATH), '/%d', $vimeo_id);
    	$vimeo = unserialize(file_get_contents("https://vimeo.com/api/v2/video/$vimeo_id.php"));
    	switch($show){
    		case 'duration' : echo date("i:s",intval($vimeo[0]['duration']));
    		break;
    		case 'thumbnail' : echo $vimeo[0]['thumbnail_large'];
    		break;
    	}
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Extract value from a function’ is closed to new replies.