Jump to content

[SOLVED] Can't seem to capture a search into arrays


Tonic-_-

Recommended Posts

Well anyways its simple.. I'm trying to addon to a IRC bot I been working on but can't get any luck with this script captuuring usernames and storing it into arrays... I'm using preg_match_all to search for : and anything after it and then store it into $matches...

 

Codex

<?php
preg_match_all("% .*?)%si", $read2[0], $matches);
$names = $matches['1'];
?>

 

 

Basically this is how the IRC prints out the name

<Tonic> bye

<UniBot> Good bye :[email protected]

 

I want to get the name after :

So far I get blank arrays...

 

Well that got pretty close.. I had to implode the array back into a string but it prints out

 

:Tonic!Tonic

 

So i'm going to work with it do a few bits of trimming and see if i can get it.

 

Alright I got it.. Imploded it and separated by , then exploded back into a array and separated the strings by , :D

 

Thanks!

There is two cells in that array.

$matches[0] = ':Tonic!' and

$matches[1] = 'Tonic'

 

Thats why you use the $matches[1] value. Not whole array together. And why you want to implode the array if you jsut want to get the name out of it?

There is two cells in that array.

$matches[0] = ':Tonic!' and

$matches[1] = 'Tonic'

 

Thats why you use the $matches[1] value. Not whole array together. And why you want to implode the array if you jsut want to get the name out of it?

 

hh that slipped my mind, been writing the bot all day that my brain is wore out. So i'll add that to trim it down some in the coding thanks man!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.