Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

culling meta data 1

Status
Not open for further replies.

bccamp

Technical User
Jan 20, 2005
69
I've got external website meta data that I'm trying to cull and insert into my db to make searchable. I'm running into a few issues with array_unique and trim.
The metadata has duplication that I'm trying to explode and remove with:

$meta=(explode(",", $meta);
$uniquemeta=array_unique($meta);
then I put into a loop with while, count, and variable $a:

$meta3=trim($uniquemeta[$a]);
I keep getting a Undefined offset error at the duplications. Any help would be appreciated, or another direction if there is an easier one to strip quotes, url's, and random #'s.
 
Can you post your code between [red][ignore]
Code:
[/ignore][/red]
tags?

Ken
 
sorry

Code:
$meta=(explode(",", $meta);
$uniquemeta=array_unique($meta);
$cnt=count($uniquemeta);
$a=0;
while ($cnt>$a) {
   $meta3=trim($uniquemeta[$a]);
   echo "meta3";
   $a++;
}

I keep getting a Undefined offset error at the duplications on the line of trim. Any help would be appreciated, or another direction if there is an easier one to strip quotes, url's, and random #'s.
 
Silly question I guess but is the first line supposed to have 2 opening parentheses but only 1 closing one?



Trojan.
 
Instead of writing the loop the way you did:
Code:
$cnt=count($uniquemeta);
$a=0;
while ($cnt>$a) {
   $meta3=trim($uniquemeta[$a]);
   echo "meta3";
   $a++;
}
Write it like:
Code:
for ($a=0;$a<count($uniquemeta);$a++) {
   $meta3=trim($uniquemeta[$a]);
   echo $meta3.'<br>';
}

See if that helps.

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top