Re: [PHP] str_replace around a character??

2011-07-13 Thread Jay Ess

On 2011-07-13 09:54, Karl DeSaulniers wrote:


$cc = ema...@domain.com ,ema...@doamin.com,ema...@domain.com , 
ema...@domain.com,  


$cc = trim($cc,,);
$result = preg_replace('/(\s?)(,)(\s?)/i', ',', $cc);


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



Re: [PHP] str_replace around a character??

2011-07-13 Thread Jay Ess

On 2011-07-13 10:36, Vitalii Demianets wrote:

On Wednesday 13 July 2011 11:09:45 Jay Ess wrote:

On 2011-07-13 09:54, Karl DeSaulniers wrote:

$cc = ema...@domain.com ,ema...@doamin.com,ema...@domain.com ,
ema...@domain.com, 

$cc = trim($cc,,);
$result = preg_replace('/(\s?)(,)(\s?)/i', ',', $cc);

The solution is broken because of:
1) you have missed spaces after comma in two places. It should be like this:
$cc = trim($cc,, ); //- here space after comma in the second argument
$result = preg_replace('/(\s?)(,)(\s?)/i', ', ', $cc); //-- the same, here
space after comma in replacement string.

Yes, that was pretty sloppy of me hehe.


2) it doesn't work with address lines like this:

To: Some   strange ,, person namestrper...@example.com

That was never the requirement ;)

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



Re: [PHP] What am I missing here?

2010-06-28 Thread Jay Ess

Rick Dwyer wrote:

Hello List.

I am completely at a loss for why the line of code below returns the 
desired value:


$PATH_INFO= substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRI
PT_NAME']), strlen($_SERVER['REQUEST_URI']));

BUT, putting the same line of code on 1 line fails to return anything:

$PATH_INFO= 
substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME']), 
strlen($_SERVER['REQUEST_URI']));

strlen counts the newline so probably should you put a +1.

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



Re: [PHP] Two color rows in table inside while iteration

2010-04-30 Thread Jay Ess

Paul M Foster wrote:

+1

This thread came up before, and tedd's solution was the least complex,
as far as I could tell. I shamelessly stole his code and regularly use
it in my own projects. ;-}
  

Or if one choose to use Smarty template.
tr bgcolor={cycle values=#ee,#d0d0d0}

http://www.smarty.net/manual/en/language.function.cycle.php

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



Re: [PHP] Structured PHP studying

2010-04-23 Thread Jay Ess

David McGlone wrote:
Is there a good strategy to studying PHP? 

For instance, is there a way to break everything down into small managable 
topics?


  
My way of learning a new language is to decide on a small project to 
code and then learn just that i need to do for that exact feature i 
implement.
That works best if you already has some knowledge in computer 
programming. And when i have grasped sufficiently i can dig into texts 
on the net for deeper understanding of the language.





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



Re: [PHP] Question on XML/XSL/PHP/MySQL

2010-01-27 Thread Jay Ess

Ryan Park wrote:
Hypothetically say that I have MySQL with petabytes of data. I want to 
use XSL as my template language. But in order to use XSL, I need to 
make XML filled with petabytes of data. This does not sound elaborate 
way to use XSL/XML; I would rather use PHP/MySQL/Smarty. Is there a 
way around this so that I can use XSL instead of Smarty?


I doubt that the generated page depends on a petabyte of data but a 
subset of that and thus you don't need to transform petabytes. Even if 
you got the hardware for it any other coworker with a clue would kick 
your ass, drag you out to the parking lot and change locks.
So if you got all this data in the DB you query for what you need and 
then transform that into your XML-data and then transform that via XSLT.


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



Re: [PHP] Wrighting to $_POST array

2009-10-12 Thread Jay Ess

hessi...@hessiess.com wrote:

I have some code which will loop over the whole $_POST array, runs it
through mysql_real_escape_string and then writes it all back to the array
again, which seams to work. Are there any incompatibility problems or such
like with writing into the $_POST or $_GET array?

function clean_post()
{
$npost = array();

while ($value = current($_POST))
{
$key = key($_POST);
$npost += array($key = mysql_real_escape_string($value));
next($_POST);
}

$_POST = $npost;
}


  


There could be problems when introducing slashes if you use other 
peoples codes. But if this is for your own code it probably wont matter.


And here is a shorter version of your code :
foreach($_POST as $key=$val)
 $_POST[$key] = mysql_real_escape_string($val);

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



Re: [Fwd: [PHP] Sessions in databases]

2009-10-09 Thread Jay Ess

Il pinguino volante wrote:

(There were some erroros in the previous email, I'm sorry)

Hi to all.

I have to realize an authentication system for a lot of users.

I heard that someone uses to store session states (?) into a database. 
I'd like to know how and, expecially, WHY to do it and what's would be 
better (considering that I CANNOT -d'oh!- edit the php.ini file).
Considering you cannot edit the php.ini-file i suspect you are on a 
shared host. Using the database for intense work in a shared environment 
is not always popular. I would guess that file based session-files are 
more scalable. And as you are using a shared hosting service you are 
probably not load balanced between physical different boxes and this 
would not gain from using the DB.
So if you have to manage a large number of user sessions i would suggest 
you choose a VPS or deducated/colo box and then use DB with memcached in 
between for fast caching. That is the way i have done it for a couple of 
sites i am working on.




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