Get Meta Tags

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 16, 2008   (RSS)

By Kenny - October 15, 2008 - edited: October 15, 2008

If using the following get_meta_tags code to extract meta tags from a particular website listed in a section in cms builder:

<?php

$tags = get_meta_tags('http://www.example.com/');

echo $tags['author'];
echo $tags['keywords'];
echo $tags['description'];

?>


How do you get http://www.example.com/ to show up correctly with http://<?php echo $webpanelRecord['domain'] ?> given that the http:// is required but not used in CMS builder.

I tried to use http://www.interactivetools.com/forum/gforum.cgi?post=63594#63594 and different variations to make sure the http:// shows up with the domain name. I always get a bunch of unexpected errors.

I've probably spent way too much time on this.... There has to be a "duh" solution to this.

Thanks!

Re: [sagentic] Get Meta Tags

By Dave - October 16, 2008

Hi sagentic,

Try one of these ways:

$tags = get_meta_tags('http://' . $webpanelRecord['domain']);

$tags = get_meta_tags("http://{$webpanelRecord['domain']}");

$domainWithHttp = 'http://' . $webpanelRecord['domain'];
$tags = get_meta_tags($domainWithHttp);

PHP only replaces variables in double quoted strings. So:

$color = 'red';
echo 'I like $color'; # prints I like $color
echo "I like $color"; # prints I like red

But with an array (as $record variables are) you need to put it in double quotes and then put curly braces around the variable so it knows where it ends.

$record['color'] = 'red';
echo "I like {$record['color']}"; # prints I like red

Hope that helps! Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com