RE: [PHP] Slight cleaning of code needed in str_replace command.

2004-02-23 Thread Dave G
Jason,
Have no worries, I'm not looking for anyone to write my code for
me. It's precisely because the str_replace command is so simple that I
figure if the results are strange that there is something I don't
understand. And I want to understand it, not just be given code to copy
and paste.
As it turns out, by experimenting with the var_dump() command
that you recommended (which I wasn't aware of), I learned that what was
going wrong was that the line breaks coming out of my MySQL DB aren't
just \n, but \r\n. So swapping around the elements I was replacing, and
experimenting, was not going to do me much good until I knew this.
So now it's working, and largely thanks to the suggestions you
gave. I would never have been able to guess on my own at using
var_dump() in order to get at the solution. Please don't assume that
just because a query is simple that it means that the person asking is
not willing to work or that they haven't already attempted to work at
it. Sometimes it just means that the person asking doesn't know all the
angles possible.

Thanks for your help.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



Re: [PHP] Slight cleaning of code needed in str_replace command.

2004-02-23 Thread Jason Wong
On Monday 23 February 2004 19:12, Dave G wrote:

   So now it's working, and largely thanks to the suggestions you
 gave. I would never have been able to guess on my own at using
 var_dump() in order to get at the solution. Please don't assume that
 just because a query is simple that it means that the person asking is
 not willing to work or that they haven't already attempted to work at
 it. Sometimes it just means that the person asking doesn't know all the
 angles possible.

It's good to know you've solved your problem. I hope you appreciate that my 
suggestions will be of more use to you in the long run than a straight 
forward answer to your problem. It's better to teach someone how to fish than 
to do the fishing for them.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
You may easily play a joke on a man who likes to argue -- agree with him.
-- Ed Howe
*/

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



Re: [PHP] Slight cleaning of code needed in str_replace command.

2004-02-21 Thread Jason Wong
On Saturday 21 February 2004 14:39, Dave G wrote:

 Any advice would be most welcome.

Well, you asked for it. The usage of str_replace() is not exactly rocket 
science, since the output is not what you expected just juggle your search  
replacement strings until it does what you want.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
At the end of your life there'll be a good rest, and no further activities
are scheduled.
*/

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



RE: [PHP] Slight cleaning of code needed in str_replace command.

2004-02-21 Thread Dave G
 Well, you asked for it. The usage of str_replace() is not 
 exactly rocket 
 science, since the output is not what you expected just 
 juggle your search  
 replacement strings until it does what you want.

It's not as if I haven't experimented with different settings, but they
haven't been successful.
In any case, rocket science or not, I was actually looking for advice
that might help me understand the logic behind the command better. I
can't see anything syntactically wrong with the string I have put
forward, so my current assumption is that there is something I don't
understand about how the string input going into the command is parsed
(it comes from a MySQL query), or about how the command interprets line
breaks.

Perhaps someone could offer something a little more concrete than
essentially recommending I just 'try different stuff'.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



Re: [PHP] Slight cleaning of code needed in str_replace command.

2004-02-21 Thread Jason Wong
On Sunday 22 February 2004 00:23, Dave G wrote:

 It's not as if I haven't experimented with different settings, but they
 haven't been successful.

By settings one usually means something which alters behaviour, as such 
str_replace() does not have any settings.

 In any case, rocket science or not, I was actually looking for advice
 that might help me understand the logic behind the command better.

It simply does a straight replacement: replace A with B in string C

 I can't see anything syntactically wrong with the string I have put
 forward, so my current assumption is that there is something I don't
 understand about how the string input going into the command is parsed
 (it comes from a MySQL query), or about how the command interprets line
 breaks.

var_dump() every variable of importance and check that they are what you 
expect them to be. You might want to wrap the output in some pre tags so 
the browser doesn't eat up your \n's.

 Perhaps someone could offer something a little more concrete than
 essentially recommending I just 'try different stuff'.

Anything more concrete would probably mean writing the code for you, that 
would be too easy (for you!).

Here's another tip: start with a small test string (forget about grabbing 
stuff from the db), do a simple replacement, check your results, make the 
string more complex, repeat.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
It takes all sorts of in  out-door schooling to get adapted
to my kind of fooling
- R. Frost
*/

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