Remove last comma from this query

Looks like you’re trying to build up some JSON. Why not use what PHP already provides, which has the advantage of escaping characters too?

global $post;

$data = array();

if ($loop->have_posts()) {
    while ($loop->have_posts()) {
        $loop->the_post();
        $thumb=wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full');
        $thumb2=wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium');
        $url = rwmb_meta( 'smb_katalozi' );

        $data[] = array (
            'image' => $thumb[0],
            'title' => get_the_title(),
            'url' => post_permalink( $url )
        );
    }
}

echo json_encode($data);