[PHP] Executing functions within ereg_replace() output

2002-04-06 Thread Adam Wan

I'm really curious as to how to output data from ereg_replace() in a
standard way.

I'm familiar with "\\1" to ouput the original string, but not sure as to how
I can use functions within the output parameter to process this value
further.

-
// here is a simple example of what i'm trying to do

$content = 'string string 12463409834234 string string';
$content = ereg_replace( "[0-9]{14}" , substr("\\1",0,5) , $content );

// this is the output i want, but the above doesnt seem to be the right way
to generate it.

string string 12363 string string


any ideas?
-Adam



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Executing functions within ereg_replace() output

2002-04-07 Thread Adam Wan

Thanks! That preg_replace_callback helps alot.

-Adam

"Cc Zona" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> In article <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] (Adam Wan) wrote:
>
> > $content = 'string string 12463409834234 string string';
> > $content = ereg_replace( "[0-9]{14}" , substr("\\1",0,5) , $content );
> >
> > // this is the output i want, but the above doesnt seem to be the right
way
> > to generate it.
> >
> > string string 12363 string string
> > 
> >
> > any ideas?
>
> For future reference:
> <http://www.php.net/preg-replace-callback>
>
> For this instance:
> $content = ereg_replace( "([0-9]{5})[0-9]{9}" , "\\1", $content);
>
> --
> CC



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: counter for HIGH traffic site

2002-04-07 Thread Adam Wan

"Craig Westerman" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I'm needing counter for site that receives 60 to 80 hits a minute. Many I
> have tried cause excessive server load and need to be deactivated or they
> lose data and return to zero without warning. All tried so far have been
> written in Perl.
>
> Anyone here know of a PHP counter that would handle HIGH traffic with
little
> added server load? Would using MySQL to store count be of any benifit?
>
> Thanks
>
> Craig ><>
> [EMAIL PROTECTED]
>

Make a mysql table that looks like this

tablename: mysqlcount
columns: "id" and "count"


Then add a single entry with "id" set to 1 and count set to 0, or whatever
your count was before.

Then use this code in your page.

$str = 'http://www.yourdomain.com/where/this/is/located'.$PHP_SELF;
if ( $str != $HTTP_REFERER ) {
mysql_query("UPDATE mysqlcount SET count=count+1 WHERE id=1");
}
$count_query = @mysql_query("SELECT count FROM mysqlcount WHERE id=1");
echo substr(@mysql_result($count_query,0),
0, -3).','.substr(@mysql_result($count_query,0), -3);

that should be pretty fast.

-Adam



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php