[PHP] Re: String is not zero-terminated in zend_execute_API.c

2011-10-21 Thread Carlos Medina
Am 21.10.2011 08:49, schrieb Daniel Betz:
> Hello List,
> 
> i am running PHP 5.3.8-FPM (with ondemand patch) in debug mode and got this 
> error every time I post an reply in vBulletin Board:
> 
> Warnung: String is not zero-terminated 
> (Z.ý4 ý4 ú}µóU) (source: 
> /usr/src/php-5.3.8/Zend/zend_execute_API.c:447) in 
> [path]/includes/functions_newpost.php(668) : eval()'d code (Zeile 34)
> 
> functions_newpost.php:
>   29 if (!$allowicons)
>   30 {
>   31 return false;
>   32 }
>   33
>   34 $membergroups = fetch_membergroupids_array($vbulletin->userinfo);
>   35 $infractiongroups = explode(',', str_replace(' ', '', 
> $vbulletin->userinfo['infractiongroupids']));
>   36
>   37 ($hook = vBulletinHook::fetch_hook('posticons_start')) ? 
> eval($hook) : false;
>   38
> 
> 
> function fetch_membergroupids_array($user, $getprimary = true)
> {
> if (!empty($user['membergroupids']))
> {
> $membergroups = explode(',', str_replace(' ', '', 
> $user['membergroupids']));
> }
> else
> {
> $membergroups = array();
> }
> 
> if ($getprimary)
> {
> $membergroups[] = $user['usergroupid'];
> }
> 
> return array_unique($membergroups);
> }
> 
> I hope you can help, or may i open an bugreport to bugs.php.net ?
> 
> Greetings,
> Daniel
> 
Hi Daniel,
do you work with a self compiled or width a distributions one?. The
failure is in the function
 zend_str_tolower(function_name_copy.value.str.val,
function_name_copy.value.str.len);

I think, if you have a self compiled or experimental version and you are
sure, that this is a bug, please place it into PHP Bugtracker. If you
are not sure, if this is a bug, becouse you change the source code or
use experimental code, use a distribution.

Greets
Carlos

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



[PHP] Re: String Encodings - loose guidelines

2011-01-26 Thread Shawn McKenzie
On 01/25/2011 02:36 PM, Donovan Brooke wrote:
> Hello,
> 
> I don't yet have a complete understanding of string encodings for the
> various environments they may need to pass through or be in. I have
> found bits and pieces within Larry's book, the online docs, and by
> googling... and
> my app seems to be working fine, but I don't yet feel confident on "best
> practices". So, I thought I'd see if I could spark some feedback to  the
> following:
> 
> 1.) Saving strings to a database

Just use the proper escaping and save what is received:
example:  mysql_real_escape_string() or a addcslashes() for DBs without
a comparable function or preg_replace() for those that escape differently:

If you definitely don't want certain things then strip them:
striptags()

If you may need it then leave it.

> 
> 2.) print/echo'ing string fields from a database.
> a. Allowing HTML?
> b. Not allowing HTML?

Depends on whether you want to render HTML.  If so, and you can trust it
(you or a trusted source entered it) then do nothing.  Otherwise if you
want to show the HTML as source tags then:
htmlentities()

If you don't want it then strip it before insert or when displaying,
your call:
striptags()

> 
> 3.) print/echo'ing string fields into form textareas.

The textarea prevents HTML inside from being rendered and the form
submit should automatically URL encode the data in the textarea so I
don't see the need to do anything.

> 
> 4.) Simply encoding strings to send over a GET request.

Encode the values that you intend to pass:
urlencode()

> 
> 5.) Simply displaying strings from the $_REQUEST array.

If you want to maybe show some HTML as source tags then:
htmlentities()

If you don't want HTML then strip it when displaying:
striptags()

> 
> 6.) string encoding for redirects
> 

Same as #4.

BTW, these are very nice for working with data:

filter_var()
filter_var_array()
filter_input()
filter_input_array()


-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: String manipulation

2010-11-14 Thread Tamara Temple


On Nov 14, 2010, at 4:48 PM, Ron Piggott wrote:


Warning: strpos() [function.strpos]: Offset not contained in string



Shouldn't you check the length of the string before giving it the  
offset?



From: a...@ashleysheridan.co.uk


$pos = (strpos(' ', $string, 76))?strpos(' ',$string,  
76):strlen($string);


Doesn't strpos(' ',$string,76) look for the first space to the *right*  
of position 76?


I really don't know how to do this except by exploding the string and  
shooting the array of characters, keeping mind of the last space found  
before you get to slot 75.



- Reply message -
From: "Ron Piggott" 


How would I write an IF statement that looks for the first space  
space (“ “) left of the 76th character

^ left


in a string or , which ever comes


first --- OR the end of the string (IE the string is less than 76  
characters long? I specifically want is it’s character position in  
the string.




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



Re: [PHP] Re: String manipulation

2010-11-14 Thread Ron Piggott
I am receiving this error:

Warning: strpos() [function.strpos]: Offset not contained in string

I have never seen it before, what do I do?  I made one change to it though, you 
didn’t have  in it before so I changed the syntax to:

$pos = (strpos(' ', $activity_description_result, 
76))?strpos('',$activity_description_result, 
76):strlen($activity_description_result);

Ron



The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

From: a...@ashleysheridan.co.uk 
Sent: Sunday, November 14, 2010 4:58 PM
To: Ron Piggott ; php-general@lists.php.net 
Subject: Re: [PHP] Re: String manipulation

What about something like this:

$pos = (strpos(' ', $string, 76))?strpos(' ',$string, 76):strlen($string);

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: "Ron Piggott" 
Date: Sun, Nov 14, 2010 20:48
Subject: [PHP] Re: String manipulation
To: 


How would I write an IF statement that looks for the first space space (“ “) 
left of the 76th character in a string or , which ever comes first --- OR 
the end of the string (IE the string is less than 76 characters long? I 
specifically want is it’s character position in the string.  Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info



Re: [PHP] Re: String manipulation

2010-11-14 Thread D. Dante Lorenso

On 11/14/10 2:48 PM, Ron Piggott wrote:

How would I write an IF statement that looks for the first space space (“ “) left of 
the 76th character in a string or, which ever comes first --- OR the end of 
the string (IE the string is less than 76 characters long? I specifically want is 
it’s character position in the string.  Ron


... but you sound like you are looking for the 'wordwrap' function.

-- Dante

--
D. Dante Lorenso
da...@lorenso.com
972-333-4139

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



Re: [PHP] Re: String manipulation

2010-11-14 Thread a...@ashleysheridan.co.uk
What about something like this:

$pos = (strpos(' ', $string, 76))?strpos(' ',$string, 76):strlen($string);

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: "Ron Piggott" 
Date: Sun, Nov 14, 2010 20:48
Subject: [PHP] Re: String manipulation
To: 


How would I write an IF statement that looks for the first space space (“ “) 
left of the 76th character in a string or , which ever comes first --- OR 
the end of the string (IE the string is less than 76 characters long? I 
specifically want is it’s character position in the string.  Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

[PHP] Re: String manipulation

2010-11-14 Thread Ron Piggott

How would I write an IF statement that looks for the first space space (“ “) 
left of the 76th character in a string or , which ever comes first --- OR 
the end of the string (IE the string is less than 76 characters long? I 
specifically want is it’s character position in the string.  Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

Re: [PHP] Re: string as file

2007-08-10 Thread Richard Lynch
Reading that, I think it's similar to this:
http://php.net/stream

I'm really not sure what the OP wants, though...



On Thu, August 9, 2007 6:32 pm, Dan wrote:
> Well, I have no idea what the Phython StringIO method does.  Could
> someone
> explain in PHP terms maybe?  Google gave me this explaining stringIO
> http://docs.python.org/lib/module-StringIO.html .  It didnt' make much
> sense
> still after reading it though.
>
> - Dan
>
> "Rick Pasotto" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Does php have a facility similar to python's stringIO?
>>
>> What I'm wanting to do is similar to a mail merge. IOW, I know I can
>> create an include file like:
>>
>> $out = <<> This is an example of $var1 and $var2.
>> EOT;
>>
>> and then after assigning values to $var1 and $var2 include that
>> file. I
>> can later use different values for $var1 and $var2 and get a
>> different
>> $out with a second include.
>>
>> Can I someout "include" a string instead of a file? Or maybe there
>> is
>> some completely different way to do what I want.
>>
>> --
>> "I have always in my own thought summed up individual liberty, and
>> business liberty, and every other kind of liberty, in the phrase
>> that is common in the sporting world, "A free field and no favor."
>> -- Woodrow Wilson, U.S. President, 1915
>>Rick Pasotto[EMAIL PROTECTED]http://www.niof.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] Re: string as file

2007-08-10 Thread Dan
Well, I have no idea what the Phython StringIO method does.  Could someone 
explain in PHP terms maybe?  Google gave me this explaining stringIO 
http://docs.python.org/lib/module-StringIO.html .  It didnt' make much sense 
still after reading it though.


- Dan

"Rick Pasotto" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

Does php have a facility similar to python's stringIO?

What I'm wanting to do is similar to a mail merge. IOW, I know I can
create an include file like:

$out = <<   Rick Pasotto[EMAIL PROTECTED]http://www.niof.net 


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



[PHP] Re: string problem

2006-07-10 Thread Rafael
	Well, if that's the pattern, you can search for >'%< and return 
anything between this and >%'<; if you can use PCRE try something like

  if ( preg_match('/'%(.+?)%'/X', $str, $matches) ) {
  echo  $matches[1];
  }
Now, if the expression can only have: upper-case letters, numbers & "-", 
then use  "/'%([-A-Z0-9]+)%'/X"  instead of  "/'%(.+?)%'/X"


weetat wrote:

Hi all ,

 I am using PHP 4.3.2 , MYSQL database and Red Hat Entreprise OS.

 I have the SQL statement which store in $str variable  as shown below :
 How to get the '%WS-X5225R%' from $str variable ?



$str = " SELECT DISTINCT(tbl_chassis.serial_no),tbl_card.card_model, ";
"tbl_chassis.host_name,tbl_chassis.chasis_model,tbl_chassis.country,";
"tbl_chassis.city,tbl_chassis.building, 
"tbl_chassis.other,tbl_chassis.status,tbl_chassis.chasis_eos,tbl_chassis.chasis_eol,tbl_chassis.chasis_user_field_1,tbl_chassis.chasis_user_field_2,tbl_chassis.chasis_user_field_3" 
"from tbl_chassis tbl_chassis,tbl_card tbl_card "
"WHERE tbl_chassis.serial_no = tbl_card.serial_no AND 
tbl_card.card_model LIKE'%WS-X5225R%'";



thanks

--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

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



Re: [PHP] Re: String /pattern formatting extraction question

2006-04-10 Thread Robin Vickery
On 10/04/06, Andy <[EMAIL PROTECTED]> wrote:
> >> text1 /ptext2 /otext3
> > Does it always look like that?
> > text1(whitespace)/ptext2(whitespace)/otext3
>
> The ideea is to extract the texts before and between /o and /p.
> $html = "asdäüü ö ö vf /pxtestxx/ostestss";
> eregi("^([^/.*]*)", $html, $reg); print_r($reg); //text is in reg[1]
> eregi("^(.*)/p([^/.*]*)", $html, $reg); print_r($reg); //text is in reg[2]
> eregi("^(.*)/o([^/.*]*)", $html, $reg); print_r($reg); //text is in reg[2]
>
> This example works, but I thought there might be a better way to extract the
> texts, with a single ereg or preg_match.

Well... slightly.

preg_match( '#^(+)/p(.+)/o(.+)$#',
preg_replace('#^(.+)(/o.+)(/p.+)$#', '$1$3$2', $html), $reg);

  -robin

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



Re: [PHP] Re: String /pattern formatting extraction question

2006-04-10 Thread Andy

text1 /ptext2 /otext3

Does it always look like that?
text1(whitespace)/ptext2(whitespace)/otext3


The ideea is to extract the texts before and between /o and /p.
$html = "asdäüü ö ö vf /pxtestxx/ostestss";
eregi("^([^/.*]*)", $html, $reg); print_r($reg); //text is in reg[1]
eregi("^(.*)/p([^/.*]*)", $html, $reg); print_r($reg); //text is in reg[2]
eregi("^(.*)/o([^/.*]*)", $html, $reg); print_r($reg); //text is in reg[2]


This example works, but I thought there might be a better way to extract the
texts, with a single ereg or preg_match.

Regards,
Andy.

- Original Message - 
From: "Barry" <[EMAIL PROTECTED]>

To: 
Sent: Monday, April 10, 2006 4:22 PM
Subject: [PHP] Re: String /pattern formatting extraction question



Andy wrote:

Hi to all, I have the following pattern for a string:

text1 /ptext2 /otext3

Does it always look like that?
text1(whitespace)/ptext2(whitespace)/otext3

Then use explode to create an array from it
explode (" ",$stringpattern);


Now, I want to extract the text by "patterns" from this string by the 
following rule:


no pattern -> text1 (what is before /o or /p)
/p -> text2 (what is after /p)
/o -> text3 (what is after /o)

Here you can use ereg and foreach
foreach ($stringpattern as $key => $value)
  {
$variable = substr_count("/",$value);
if ($variable > 0) / has been found now extract the first two chars
  }

Or something like that ~


--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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





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



[PHP] Re: String /pattern formatting extraction question

2006-04-10 Thread Barry

Andy wrote:
Hi to all, 


I have the following pattern for a string:

text1 /ptext2 /otext3

Does it always look like that?
text1(whitespace)/ptext2(whitespace)/otext3

Then use explode to create an array from it
explode (" ",$stringpattern);


Now, I want to extract the text by "patterns" from this string by the following 
rule:

no pattern -> text1 (what is before /o or /p)
/p -> text2 (what is after /p)
/o -> text3 (what is after /o)

Here you can use ereg and foreach
foreach ($stringpattern as $key => $value)
  {
$variable = substr_count("/",$value);
if ($variable > 0) / has been found now extract the first two chars
  }

Or something like that ~


--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



[PHP] Re: string to integer conversion

2006-03-15 Thread João Cândido de Souza Neto
Try this:

$accno="2927";
$accno=substr("",0,(8-strlen($accno+1))).($accno+1);

I don't test, but i hope it'll work fine.

 
suresh kumar wrote:

> i am facing one problem in type casting.
> $accno="2927";
> $accno=$accno+1;
> its o/p is 2928. but i want output to be 2928.i am
> waiting response from u.
> 
> 
> 
> __
> Yahoo! India Matrimony: Find your partner now. Go to
> http://yahoo.shaadi.com

-- 
---
João Cândido de Souza Neto
Web Developer

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



[PHP] Re: string size in bytes

2006-02-12 Thread Eli

benifactor wrote:

also i need to know how to find out how fast a page renders

example;

page rendered in 1.114 seconds





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



[PHP] Re: string lenght?

2006-02-12 Thread Eli

William Stokes wrote:

How can I test whether a string is 1 or 2 digits long?


You can use regular expressions:

preg_match('/^\d{1,2}$/',$str);

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



[PHP] Re: string lenght?

2006-02-06 Thread Barry

William Stokes wrote:

Hello,

How can I test whether a string is 1 or 2 digits long?

Thanks
-Will

strlen() -_-

RTFM

www.php.net/strlen

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



[PHP] Re: string to .ZIP | sending report by email

2005-08-23 Thread Manuel Lemos

Hello,

on 08/23/2005 02:13 PM Ing. Josué Aranda said the following:

I have a script that generate a XHTML report, but also i want to send
that report by email, the problem is the file size its up to 4Mb, its
too big to send by email (considering that some people still using
hotmail).. how i can send it compressed by email? anyone knows a class
that can help me?


Here you may find several solutions for your problem:

http://www.phpclasses.org/browse/class/42/top/rated.html

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

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



Re: [PHP] Re: string highlight

2005-06-08 Thread John Nichel

Rory Browne wrote:


< won't be picked up as a word boundry (\b).


Aparently it will.



I stand corrected based on these two rules for \b since < and > are 
non-word characters...


# Between a word character and a non-word character following right 
after the word character.
# Between a non-word character and a word character following right 
after the non-word character.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Re: string highlight

2005-06-08 Thread Rory Browne
On 6/8/05, John Nichel <[EMAIL PROTECTED]> wrote:
> Rory Browne wrote:
> 
> >>Good catch Rory.  A regex replace would work better here.
> >>
> >>$search = "body";
> >>$find = "/\b" . $search . "\b/";
> >>preg_replace ( $find, "" . $search . "", $html );
> >
> >
> > I don't think so. If I'm reading your code correctly you still have
> > the same problem, as I outlined above. There is no simple solution to
> > this. It either involves advanced regex(more advanced than my
> > understanding of it), or a proper parser.
> >
> >  >
> > function highlight_html_string($needle, $haystack);
> >
> > $retval = "";
> > $i = 0;
> > while($i < strlen($haystack)){
> >   $str = get_text_between_certain_point_and_first_instance_of_<($i);
> >   $str = preg_replace(what john said above);
> >   $str .= get_tag_text($i);
> >   $retval .= $str;
> >   $i += strlen($str);
> > }
> >
> > return $retval;
> > ?>
> 
> < won't be picked up as a word boundry (\b).
Aparently it will.

[EMAIL PROTECTED] tmp]$ cat /tmp/test.php
Highlight the body of the text";

echo preg_replace("/\bbody\b/", "body", $str);

?>
[EMAIL PROTECTED] tmp]$ php -q /tmp/test.php
Highlight the body of the textbody>



> 
> --
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> [EMAIL PROTECTED]
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



Re: [PHP] Re: string highlight

2005-06-08 Thread John Nichel

Rory Browne wrote:


Good catch Rory.  A regex replace would work better here.

$search = "body";
$find = "/\b" . $search . "\b/";
preg_replace ( $find, "" . $search . "", $html );



I don't think so. If I'm reading your code correctly you still have
the same problem, as I outlined above. There is no simple solution to
this. It either involves advanced regex(more advanced than my
understanding of it), or a proper parser.

  $str = get_text_between_certain_point_and_first_instance_of_<($i); 
  $str = preg_replace(what john said above);

  $str .= get_tag_text($i);
  $retval .= $str;
  $i += strlen($str);
}

return $retval;
?>


< won't be picked up as a word boundry (\b).

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Re: string highlight

2005-06-08 Thread Rory Browne
On 6/8/05, Jay Blanchard <[EMAIL PROTECTED]> wrote:
> [snip]
> I don't think so. If I'm reading your code correctly you still have
> the same problem, as I outlined above. There is no simple solution to
> this. It either involves advanced regex(more advanced than my
> understanding of it), or a proper parser.
> 
>  
> function highlight_html_string($needle, $haystack);
> 
> $retval = "";
> $i = 0;
> while($i < strlen($haystack)){
>   $str = get_text_between_certain_point_and_first_instance_of_<($i);
>   $str = preg_replace(what john said above);
>   $str .= get_tag_text($i);
>   $retval .= $str;
>   $i += strlen($str);
> }
> 
> return $retval;
> ?>
> [/snip]
> 
> Also it should be noted that the  tag pair has really been depricated
> in favor of  tags. Here is another thought, can you ignore your
> search string where it has tags immediately before and after it, so that
> >body< could be ignored?
> 
Hmmm, that would solve the above specific mentioned problem. how about
something like  or  assuming
that body is the word to be highlighted.

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



RE: [PHP] Re: string highlight

2005-06-08 Thread Jay Blanchard
[snip]
I don't think so. If I'm reading your code correctly you still have
the same problem, as I outlined above. There is no simple solution to
this. It either involves advanced regex(more advanced than my
understanding of it), or a proper parser.


[/snip]

Also it should be noted that the  tag pair has really been depricated
in favor of  tags. Here is another thought, can you ignore your
search string where it has tags immediately before and after it, so that
>body< could be ignored?

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



Re: [PHP] Re: string highlight

2005-06-08 Thread Jochem Maas

Rory Browne wrote:

On 6/8/05, John Nichel <[EMAIL PROTECTED]> wrote:


Rory Browne wrote:


On 6/8/05, David Duong <[EMAIL PROTECTED]> wrote:



Sebastian wrote:



i'm looking for a function that can highlight certain search terms in a
string. anyone have something already made that i can plugin to my
exisiting code?

I found a couple but they do not work very well.. some break html code
if the string contains the keywords in the html.

thanks.


You can use str_replace to "highlight" the search terms.

For example, you could use the following code for each search term (this
function also accepts arrays, see http://php.net/str_replace):

str_replace ($search_term, "$search_term", $body_text);



Bad idea. Very bad idea.

for example ( using bold to highlight ):
I want to hightlight the word body in this text.
";
$search = "body";

$output = str_replace($search, "$search", $html);
// $output == "I want to hightlight the word
body in this text. body>";

// see what I mean?
?>


Good catch Rory.  A regex replace would work better here.

$search = "body";
$find = "/\b" . $search . "\b/";
preg_replace ( $find, "" . $search . "", $html );



I don't think so. If I'm reading your code correctly you still have
the same problem, as I outlined above. There is no simple solution to


John is using \b in his regexp to denote a word boundary - I don't believe
< counts as a boundary char therefore niether '' or ''
would be preg_replace()'d


this. It either involves advanced regex(more advanced than my
understanding of it), or a proper parser.

  $str = get_text_between_certain_point_and_first_instance_of_<($i); 
  $str = preg_replace(what john said above);

  $str .= get_tag_text($i);
  $retval .= $str;
  $i += strlen($str);
}

return $retval;
?>


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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







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



Re: [PHP] Re: string highlight

2005-06-08 Thread Jochem Maas

John Nichel wrote:

Rory Browne wrote:


On 6/8/05, David Duong <[EMAIL PROTECTED]> wrote:


Sebastian wrote:


i'm looking for a function that can highlight certain search terms in a
string. anyone have something already made that i can plugin to my
exisiting code?

I found a couple but they do not work very well.. some break html code
if the string contains the keywords in the html.

thanks.



You can use str_replace to "highlight" the search terms.

For example, you could use the following code for each search term (this
function also accepts arrays, see http://php.net/str_replace):

str_replace ($search_term, "$search_term", $body_text);




Bad idea. Very bad idea.
for example ( using bold to highlight ):
I want to hightlight the word body in this text.
";
$search = "body";

$output = str_replace($search, "$search", $html);
// $output == "I want to hightlight the word
body in this text. body>";

// see what I mean?
?>



Good catch Rory.  A regex replace would work better here.

$search = "body";
$find = "/\b" . $search . "\b/";


if I were Richard Lynch I would mention that you probably want to backslash
your backslashes:

$find = "/\\b" . $search . "\\b/";

but then again if I were Richard Lynch I would probably assume that John Nichel
knows that kind of thing, therefore I would not bother mentioning it, or
would I?

what would Richard Lynch say?

(no offence Richard!, Im just being playful :-)
(btw Richard is right about the backslashing!)


preg_replace ( $find, "" . $search . "", $html );



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



Re: [PHP] Re: string highlight

2005-06-08 Thread Rory Browne
On 6/8/05, John Nichel <[EMAIL PROTECTED]> wrote:
> Rory Browne wrote:
> > On 6/8/05, David Duong <[EMAIL PROTECTED]> wrote:
> >
> >>Sebastian wrote:
> >>
> >>>i'm looking for a function that can highlight certain search terms in a
> >>>string. anyone have something already made that i can plugin to my
> >>>exisiting code?
> >>>
> >>>I found a couple but they do not work very well.. some break html code
> >>>if the string contains the keywords in the html.
> >>>
> >>>thanks.
> >>
> >>You can use str_replace to "highlight" the search terms.
> >>
> >>For example, you could use the following code for each search term (this
> >>function also accepts arrays, see http://php.net/str_replace):
> >>
> >>str_replace ($search_term, "$search_term", $body_text);
> >
> >
> > Bad idea. Very bad idea.
> >
> > for example ( using bold to highlight ):
> >  >
> > $html = "I want to hightlight the word body in this text.
> > ";
> > $search = "body";
> >
> > $output = str_replace($search, "$search", $html);
> > // $output == "I want to hightlight the word
> > body in this text. body>";
> >
> > // see what I mean?
> > ?>
> 
> Good catch Rory.  A regex replace would work better here.
> 
> $search = "body";
> $find = "/\b" . $search . "\b/";
> preg_replace ( $find, "" . $search . "", $html );

I don't think so. If I'm reading your code correctly you still have
the same problem, as I outlined above. There is no simple solution to
this. It either involves advanced regex(more advanced than my
understanding of it), or a proper parser.



> 
> --
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> [EMAIL PROTECTED]
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



Re: [PHP] Re: string highlight

2005-06-08 Thread John Nichel

Rory Browne wrote:

On 6/8/05, David Duong <[EMAIL PROTECTED]> wrote:


Sebastian wrote:


i'm looking for a function that can highlight certain search terms in a
string. anyone have something already made that i can plugin to my
exisiting code?

I found a couple but they do not work very well.. some break html code
if the string contains the keywords in the html.

thanks.


You can use str_replace to "highlight" the search terms.

For example, you could use the following code for each search term (this
function also accepts arrays, see http://php.net/str_replace):

str_replace ($search_term, "$search_term", $body_text);



Bad idea. Very bad idea. 


for example ( using bold to highlight ):
I want to hightlight the word body in this text.
";
$search = "body";

$output = str_replace($search, "$search", $html);
// $output == "I want to hightlight the word
body in this text. body>";

// see what I mean?
?>


Good catch Rory.  A regex replace would work better here.

$search = "body";
$find = "/\b" . $search . "\b/";
preg_replace ( $find, "" . $search . "", $html );

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Re: string highlight

2005-06-07 Thread Rory Browne
On 6/8/05, David Duong <[EMAIL PROTECTED]> wrote:
> Sebastian wrote:
> > i'm looking for a function that can highlight certain search terms in a
> > string. anyone have something already made that i can plugin to my
> > exisiting code?
> >
> > I found a couple but they do not work very well.. some break html code
> > if the string contains the keywords in the html.
> >
> > thanks.
> You can use str_replace to "highlight" the search terms.
> 
> For example, you could use the following code for each search term (this
> function also accepts arrays, see http://php.net/str_replace):
> 
> str_replace ($search_term, "$search_term", $body_text);

Bad idea. Very bad idea. 

for example ( using bold to highlight ):
I want to hightlight the word body in this text.
";
$search = "body";

$output = str_replace($search, "$search", $html);
// $output == "I want to hightlight the word
body in this text. body>";

// see what I mean?
?>


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

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



[PHP] Re: string highlight

2005-06-07 Thread David Duong

David Duong wrote:

Sebastian wrote:

i'm looking for a function that can highlight certain search terms in 
a string. anyone have something already made that i can plugin to my 
exisiting code?


I found a couple but they do not work very well.. some break html code 
if the string contains the keywords in the html.


thanks.


You can use str_replace to "highlight" the search terms.

For example, you could use the following code for each search term (this 
function also accepts arrays, see http://php.net/str_replace):


str_replace ($search_term, "$search_term", $body_text);

 - David
I forgot to mention that if you wanted to have a highlighting effect, 
you will need to use stylesheets.


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



[PHP] Re: string highlight

2005-06-07 Thread David Duong

Sebastian wrote:
i'm looking for a function that can highlight certain search terms in a 
string. anyone have something already made that i can plugin to my 
exisiting code?


I found a couple but they do not work very well.. some break html code 
if the string contains the keywords in the html.


thanks.

You can use str_replace to "highlight" the search terms.

For example, you could use the following code for each search term (this 
function also accepts arrays, see http://php.net/str_replace):


str_replace ($search_term, "$search_term", $body_text);

 - David

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



[PHP] Re: String to Date and Date to String Functions?

2005-01-24 Thread David Robley
On Tuesday 25 January 2005 03:01, Ben Edwards wrote:

> Being trying to work out haw to handle dates.  Basically I need a
> function to convert a Date to a String and another function to convert
> a string to a date.
> 
> Exactly what format the date is held in is not relevant as long as it
> is some type of  standard (i.e. Unix Timestamps).
> 
> Both the functions will require a format string (such ad DD/MM/YYY)
> and again the format/syntax of this is irrelevant, as long as they are
> the same for both .
> 
> String to Date Function
> 
> return date stringToDate( str Date, str Format )
> e.g. $todayDt = stringToDate( '01/01/2003','DD/MM/' );
> 
> Date to String Function
> 
> return str dateToString( date Date, str Format )
> e.g. $todayStr = dateToString ( $todayDt,'DD/MM/' );
> 
> Anyone know of any functions that do this or have pointers as to how
> it can be done.
> 
> Ben

Have you looked at date() and strtotime() ?

-- 
David Robley

How do you make Windows faster ? Throw it harder

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



[PHP] Re: string filtering

2004-07-21 Thread Mr. Bogomil Shopov
Hello
http://bg2.php.net/manual/en/function.preg-match.php
Regards
Bogomil
http://spisanie.com/indexen.php - WebDevMagazine

C.F. Scheidecker Antunes wrote:
Hello all,
I need to filter some strings. They can only contain characters like 
a...z or A..Z and 0..9. Some strings have blank spaces, -,./?>,< 
characters that must be discarded. I wrote a function to check each and 
every character but I guess there must be something else more efficient.

Any suggestions?
Thanks in advance.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: string

2004-07-05 Thread water_foul
from help me with eregi:

sorry i didn't relise i did that till just now

"Richard Davey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> w> ho do you make a eregi so it looks at the var as a single line
>
> If anyone helps you after you posted 15KB of pointless HTML.. twice..
> I'll be amazed.
>
> Best regards,
>
> Richard Davey
> -- 
>  http://www.launchcode.co.uk - PHP Development Services
>  "I am not young enough to know everything." - Oscar Wilde

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



[PHP] Re: string

2004-07-05 Thread water_foul
oh 1 more thing.. i am looking for:

but in the html it shows up as:

 
-
"Water_foul" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> ok i've stripped some html from a page and my eregi didn't work, so i
> put it into a text box so i could see what the variable has in it... and i
> got this:
> ---
> Anyone can play on the Free Worlds below
>  
>  
>  
> src=http://www.runescape.com/img/gamewin/usflag.gif width=30 height=15
> border=0> UnitedLayer
>   href=client.cgi?world=1&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 1
>  2000 players
>   
> src=http://www.runescape.com/img/gamewin/usflag.gif width=30 height=15
> border=0> Peer1
>   href=client.cgi?world=3&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 3
>  1290 players
>   href=client.cgi?world=4&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 4
>  1149 players
>   href=client.cgi?world=5&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 5
>  1157 players
>   
> src=http://www.runescape.com/img/gamewin/usflag.gif width=30 height=15
> border=0> AboveNet
>   href=client.cgi?world=7&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 7
>  1154 players
>   href=client.cgi?world=8&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 8
>  1115 players
>  
>  
> src=http://www.runescape.com/img/gamewin/usflag.gif width=30 height=15
> border=0> Philadelphia
>   href=client.cgi?world=10&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 10
>  1274 players
>   href=client.cgi?world=11&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 11
>  1151 players
>   
> src=http://www.runescape.com/img/gamewin/usflag.gif width=30 height=15
> border=0> NLayer
>   href=client.cgi?world=13&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 13
>  1147 players
>   href=client.cgi?world=14&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 14
>  1148 players
>  
>  
> src=http://www.runescape.com/img/gamewin/ukflag.gif width=30 height=15
> border=0> London
>   href=client.cgi?world=15&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 15
>  1746 players
>   href=client.cgi?world=23&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 23
>  1195 players
>   
> src=http://www.runescape.com/img/gamewin/canadaflag.gif width=30 height=15
> border=0> Toronto
>   href=client.cgi?world=17&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 17
>  1669 players
>   
> src=http://www.runescape.com/img/gamewin/usflag.gif width=30 height=15
> border=0> CET
>   href=client.cgi?world=19&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 19
>  1067 players
>   href=client.cgi?world=20&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 20
>  1097 players
>   href=client.cgi?world=25&plugin=-1&lores=0&rand=4843862
> oncontextmenu=return(false) target="_parent" class=c>World 25
>  1128 players
>  
>  
>  
>  
>  
>  
>  
>  
>  
>
>  
> background='http://www.runescape.com/img/stoneback.gif'>
>  
>  
>  Rules of conduct
>
>  Know the rules - don't risk being banned from the game
>  
>
>  
>
>
>  
>
> background='http://www.runescape.com/img/stoneback.gif'>
>  
>  
>  Become a Member
>  Access exclusive benefits for only $5 a month!
>  
>
>  
>
>
>  
> background='http://www.runescape.com/img/stoneback.gif'>
>  
>  
>  Security tips
>  Protect your password and read this important information
>  
>
>  
>
> 
>  
>  
>  
>  
>  
>  
>  
>   
>  
>  http://www.runescape.com/img/playgame/swordarrow.gif";
border="0">
>  
>   
>  
>  
>  
>  
>  
>  
>  
>
>  
> background='http://www.runescape.com/img/stoneback.gif'>
>  
>  
>  Rules of conduct
>
>  Know the rules - don't risk being banned from the game
>  
>
>  
>
>
>  
>
> background='http://www.runescape.com/img/stoneback.gif'>
>  
>  
>  Become a Member
>  Access exclusive benefits 

[PHP] Re: string replace in files

2004-04-30 Thread Justin Patrin
Steve Buehler wrote:

I am trying to write a script that will replace a string in a file.  
Actually, about 3000 files.  And I am stuck.  I can get the list of 
files, but then I pretty much become stuck.  I wanted to try 
str_ireplace (not sure if that is what I should use or not), but I can't 
even get far enough to do that.  I am hoping that someone out there has 
an easy response to this.  Below is the code that I have so far.
Thanks
Steve

#!/usr/bin/php
http://www.domain.com/";;
$replacewithstring="require \"/home/domain/www/";
replacestring();

function replacestring(){
GLOBAL $strtoreplace,$replacewithstring;
$FILES=array(`ls -1 */*|grep .php`);
foreach($FILES as $value){
if($value){
echo "file $value\n";
$handle=fopen($value,'a');
}
}
}
?>
^_^
You could use PEAR's File_SearchReplace.
http://pear.php.net/package/File_SearchReplace
A few lines of code and it's all done for you. :-)

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


Re: [PHP] Re: string function that inserts a char

2004-03-20 Thread Five

"Jason Giangrande" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Five wrote:
> > "Five" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> >
> >>I just finished looking through string functions
> >>http://us2.php.net/manual/en/ref.strings.php
> >>and can't find one that inserts a character, not replaces one.
> >>
> >>If there's a string that's over 50 chars long without a space, I want to insert a 
> >>space without replacing or losing any of the
> >>original characters. Is there a function to do that?
> >>
> >>advance thanks,
> >>Dale
> >
> >
> > I should add that, unless there's a function that does it all, I'm not really 
> > concerned with the finding the 50th char part. I
know
> > there's other funcs for that kind of thing. It's just that all I'm trying to do is 
> > make sure that when the string is output, it
will
> > wrap to the width of a table and not stretch the table width to suit it's fancy.
> > If I manufacture a function to do all of the little things necessary to make this 
> > thing wrap, it seems like a lot of ugly code
to do
> > a simple task.
> >
>
> Use substr_replace() and set the length value to 0.  Here's an example:
>
> $text = "Thistext";
> echo "$text";
> $text = substr_replace($text, " ", 4, 0);
> echo $text;
>
> Test it and you will see that a space is added into the text without
> replacing any of it.
>
> -- 
> Jason Giangrande <[EMAIL PROTECTED]>
> http://www.giangrande.org
> http://www.dogsiview.com


Thanks Jason

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



Re: [PHP] Re: string function that inserts a char

2004-03-20 Thread Jason Giangrande
Five wrote:
"Five" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]

I just finished looking through string functions
http://us2.php.net/manual/en/ref.strings.php
and can't find one that inserts a character, not replaces one.
If there's a string that's over 50 chars long without a space, I want to insert a 
space without replacing or losing any of the
original characters. Is there a function to do that?
advance thanks,
Dale


I should add that, unless there's a function that does it all, I'm not really 
concerned with the finding the 50th char part. I know
there's other funcs for that kind of thing. It's just that all I'm trying to do is 
make sure that when the string is output, it will
wrap to the width of a table and not stretch the table width to suit it's fancy.
If I manufacture a function to do all of the little things necessary to make this 
thing wrap, it seems like a lot of ugly code to do
a simple task.
Use substr_replace() and set the length value to 0.  Here's an example:

$text = "Thistext";
echo "$text";
$text = substr_replace($text, " ", 4, 0);
echo $text;
Test it and you will see that a space is added into the text without 
replacing any of it.

--
Jason Giangrande <[EMAIL PROTECTED]>
http://www.giangrande.org
http://www.dogsiview.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: string function that inserts a char

2004-03-20 Thread Five

"Five" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> I just finished looking through string functions
> http://us2.php.net/manual/en/ref.strings.php
> and can't find one that inserts a character, not replaces one.
>
> If there's a string that's over 50 chars long without a space, I want to insert a 
> space without replacing or losing any of the
> original characters. Is there a function to do that?
>
> advance thanks,
> Dale

I should add that, unless there's a function that does it all, I'm not really 
concerned with the finding the 50th char part. I know
there's other funcs for that kind of thing. It's just that all I'm trying to do is 
make sure that when the string is output, it will
wrap to the width of a table and not stretch the table width to suit it's fancy.
If I manufacture a function to do all of the little things necessary to make this 
thing wrap, it seems like a lot of ugly code to do
a simple task.

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



Re: [PHP] Re: String Manip. - Chop Equivalent

2003-11-23 Thread Robert Cummings
On Sun, 2003-11-23 at 20:02, Al wrote:
> >From the PHP Manual notes (http://us2.php.net/manual/en/function.chop.php):
> 
> $string = substr("$string", 0, -1);

You'd be better off with:

$string = substr( $string, 0, -1 );

to avoid unnecessary interpolation overhead.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Re: String Manip. - Chop Equivalent

2003-11-23 Thread Al
>From the PHP Manual notes (http://us2.php.net/manual/en/function.chop.php):

$string = substr("$string", 0, -1);


Al

"Jed R. Brubaker" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Does PHP have an equivalent to PERL's chop - that is, a way to get rid of
> the last character in a string?
>
> "Hello World" to "Hello Worl"
>
> Thanks in advance.

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



[PHP] Re: String Manip. - Chop Equivalent

2003-11-23 Thread Terence
Jed R. Brubaker wrote:

Does PHP have an equivalent to PERL's chop - that is, a way to get rid of
the last character in a string?
"Hello World" to "Hello Worl"

Thanks in advance.
this might work, haven't tested it...
second param is optional
function chop($strSubject, $intWastage = 1) {
  $strRes = "";
  $len = strlen($strSubject);
  if($intWastage <= $len && $intWastage >= ($len * (-1)))
$strRes = substr($strSubject,0,$len - $intWastage);
  return $strRes;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: String matching for sample code doesn't work....

2003-11-19 Thread Scott Fletcher
Never mind that!  It work now  Been working on it for a few hours
though

"Scott Fletcher" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi Everyone!
>
> I'm not really sure why does this simple script not work.  When I run
> the code, the loop kept going until it timed out.  I'll enclose the simple
> code here...
>
> --snip--
>$res_str = "Whoof";
>
>for ($i=0;$i<100;$i++)
>{
>   if (substr($res_str, $i, 9) == "

[PHP] Re: String to Array or Hash Table

2003-10-20 Thread Manuel Vázquez Acosta
Try:
parse_str($theStr, $assocArray);


Manu.

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



[PHP] Re: String formatting function - First char Upper, rest lower

2003-09-06 Thread Thomas Hebinck
Hi,

>Does anyone know of a function or script that will capitalize the first
char
>and lowercase the remaining chars of each word in a string?

from the documentation:

$bar = ucwords(strtolower($bar));

http://de.php.net/manual/en/function.ucwords.php

Bye,
Thomas.

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



[PHP] Re: string concatenation from array

2003-08-14 Thread Micah Montoy
Thanks a bunch.  Problem solved.


"Micah Montoy" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm having a bit of difficulty getting a string to attach to itself from
an
> array.  Here is the bit of code I'm working on.
>
> $wresult = "";
>
>  foreach ($search_string as $word_result){
>   $wresult = $wresult & " " & $word_result;
>  }
>
> echo ("$wresult");
>
> Anyone see why when I run through each part of the array, it won't attach
> the next string and so on?
>
> thanks
>
>



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



[PHP] Re: string concatenation from array

2003-08-14 Thread Fabio Rotondo
Micah Montoy wrote:
I'm having a bit of difficulty getting a string to attach to itself from an
array.  Here is the bit of code I'm working on.
$wresult = "";

 foreach ($search_string as $word_result){
  $wresult = $wresult & " " & $word_result;
 }
what about:

$wresult = join ( " ", $search_string );

Ciao,

  Fabio

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


[PHP] Re: string validating

2003-03-12 Thread Brad Esclavon
trim($a_string); // removes all newline, carriage returns, and formating


$in_str_var_name=str_replace("search_for", "replace_with",
$in_str_var_name);

replaces any strings or chars

also- check out php.net documentation on string-- many other useful
functions for string manipulation




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



[PHP] Re: string

2002-11-29 Thread Kyle Gibson
hi everyone..
how to get the part of string and make it into a variable..
sample :
  "determine"
now, i want to take just "mine" or 4 word from right, or "deter" (for 
left function).
and after i got it, i want to make the "mine" into $x variable
my mind..
$x = "mean"
help please...

$x = substr("determine",-4);

For more information on SUBSTR,

http://www.php.net/manual/en/function.substr.php

;)

--
Kyle Gibson
admin(at)frozenonline.com
http://www.frozenonline.com/


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




[PHP] Re: String manipulation

2002-10-24 Thread Erwin

"Francisco Vaucher" <[EMAIL PROTECTED]> wrote in message
news:3B966ABC166BAF47ACBF4639003B11AC848AE7@;exchange.adtarg.com...
>
> Hi to all (again ;-)
>
> I need one or more PHP functions to handle a form input.
>
> i.e. you write: [EMAIL PROTECTED]
>
> I have to check that after the '@' comes 'test.com'. I think this is easy,

Something like this?

$address = explode( '@', $_POST['email'] );
if ( $address[1] == 'test.com' )
echo 'Valid';
else
echo 'Not valid';

or:

if ( preg_match( '/.*@test\.com$/', $_POST['email'] ) )
echo 'Valid';
else
echo 'Not valid';

$_POST['email'] contains the email address, submitted by the form.

HTH
Erwin


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




[PHP] Re: String extraction from blobs. Extracted string to be placedinto field within another table.

2002-10-20 Thread Manuel Lemos
Hello,

On 10/19/2002 11:13 PM, Dwalker wrote:

What is the most effective method of extracting from a blob specified 
text to be placed into another table field.

If you use Metabase it allows you to create prepared queries where you 
can pipe data from blob returned by a select query to a blob to be 
updated or inserted by another query, with minimal memory usage, thus 
allowing to manipulate large sized blobs.

Metabase is a database independent abstraction layer so it works with 
many supported databases:

http://www.phpclasses.org/metabase

--

Regards,
Manuel Lemos


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



[PHP] Re: string...

2002-04-12 Thread Michael Virnstein

beware if you're using preg_match instead.
regex using preg_match have to be enclosed by /
so the same with preg_match would look like:
preg_match("/^.*_[0-9]{4}\.jpg$/i", $file_name)
and using preg_match meens that / is a special character and has to be
backslashed if
wanted by it's meening. and there's nothing like preg_matchi to check
case-insensitive.
this has to be done using modifiers after the ending /. in the example above
it's i for case-insensitive.


"Michael Virnstein" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> wrong again:
> eregi("^/*_[0-9]{4}\.jpg$", $file_name)
>
> now yo say, / at the beginning between 0 and unlimited times, the rest is
> ok.
>
> try this, i rechecked my second example and saw that i did a \. at the
> beginning. this was wrong,
> because it'll search for a dot at the beginning. simply forget about the
> backslash before the first dot.
> This should finally work:
> eregi("^.*_[0-9]{4}\.jpg$", $file_name)
>
> . is a special character and meens every character. so if you want . by
it's
> meening you have to
> backslash it: \.
> so what my ereg meens now, is the following:
> any character at the beginning between 0 and unlimited times, followed by
an
> _, followed
> by 4 characters between 0 and 9 followed by a dot, followed by jpg which
has
> to be at the end of the string.
>
> Michael
>
> "Jas" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Ok, I have tried all 3 examples and even tried a few variations that you
> > have given me and so far nothing is getting displayed, is there a way to
> > check for errors?  here is the code I am working with:
> >
> > // second selection for main image on main page
> > $dir_name = "/path/to/images/directory/";
> > $dir = opendir($dir_name);
> > $file_lost .= " > NAME=\"images\">
> > ";
> >  while ($file_names = readdir($dir)) {
> >   if ($file_names != "." && $file_names !=".." &&
> > eregi("^/*_[0-9]{4}\.jpg$", $file_name)) {
> >   $file_lost .= " > NAME=\"$file_names\">$file_names";
> >   }
> >  }
> >  $file_lost .= " > VALUE=\"select\">";
> >  closedir($dir);
> >
> >
> > "Michael Virnstein" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > and i'd suggest using eregi instead, because then also .Jpg or .JPG
will
> > be
> > > found.
> > >
> > > "Michael Virnstein" <[EMAIL PROTECTED]> schrieb im
Newsbeitrag
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > see what's wrong here:
> > > > ereg('(^[0-1231]$).jpg$',$file_name)
> > > >
> > > > [] meens a group of characters, so in your case
> > > > 0,1,2 and 3 are valid characters. you haven't defined any
> > > > modifer like ?,*,+ or{}, so one of this characters has to
> > > > be found exactly one time. you're using ^ outside the [] so it meens
> the
> > > > beginning of the string.
> > > > in your case none of these characters inside the [] can be found at
> the
> > > > beginning of the string.
> > > > then you use $ after the []. $ meens the end of the string. none of
> the
> > > > characters in the [] matches at the end of the string.
> > > > so this would be right:
> > > >
> > > > ereg('_[0-9]{4}\.jpg$', $file_name);
> > > >
> > > > so this meens:
> > > > the beginning of the string doesn't matter, because we have not
> > specified
> > > ^
> > > > at the beginning.
> > > > there has to be an underscore, followed by 4 characters between 0
and
> 9,
> > > > followed by an dot,
> > > > followed by j, followd by p, followed by g. g has to be at the end
of
> > the
> > > > string, because of the $.
> > > > or you can use:
> > > > ereg('^\.*_[0-9]{4}\.jpg$', $file_name);
> > > >
> > > > this will meen :
> > > > any characters at the beginning between 0 and unlimited times, then
> > > followed
> > > > by an underscore,
> > > > followed by 4 characters between 0 and 9, followed by a dot,
followed
> by
> > > > jpg. same as above
> > > > though. But the * is a real performance eater so it could be
slightly
> > > faster
> > > > if you're using the first example.
> > > >
> > > >
> > > >
> > > > "Jas" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> > > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > > I hate to say it but that didn't work, I have been trying
different
> > > > > variations of the same ereg('_(^90-9{4}$).jpg$',$file_names) and
> > nothing
> > > > > seems to work for me, I have also been looking at the ereg and
> > preg_ereg
> > > > > functions but they don't seem to make sense to me, here is the
code
> as
> > a
> > > > > whole if this helps:
> > > > > // query directory and place results in select box
> > > > > $dir_name = "/path/to/images/directory/on/server/"; // path to
> > directory
> > > > on
> > > > > server
> > > > > $dir = opendir($dir_name); // open the directory in question
> > > > > $file_lost .= " > > > NAME=\"ad01\">
> > > > > ";
> > > > >  while ($file_names = readdir($dir)) {
> > > > >   if ($file_names != "." && $file_names !=

[PHP] Re: string...

2002-04-12 Thread Michael Virnstein

wrong again:
eregi("^/*_[0-9]{4}\.jpg$", $file_name)

now yo say, / at the beginning between 0 and unlimited times, the rest is
ok.

try this, i rechecked my second example and saw that i did a \. at the
beginning. this was wrong,
because it'll search for a dot at the beginning. simply forget about the
backslash before the first dot.
This should finally work:
eregi("^.*_[0-9]{4}\.jpg$", $file_name)

. is a special character and meens every character. so if you want . by it's
meening you have to
backslash it: \.
so what my ereg meens now, is the following:
any character at the beginning between 0 and unlimited times, followed by an
_, followed
by 4 characters between 0 and 9 followed by a dot, followed by jpg which has
to be at the end of the string.

Michael

"Jas" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Ok, I have tried all 3 examples and even tried a few variations that you
> have given me and so far nothing is getting displayed, is there a way to
> check for errors?  here is the code I am working with:
>
> // second selection for main image on main page
> $dir_name = "/path/to/images/directory/";
> $dir = opendir($dir_name);
> $file_lost .= " NAME=\"images\">
> ";
>  while ($file_names = readdir($dir)) {
>   if ($file_names != "." && $file_names !=".." &&
> eregi("^/*_[0-9]{4}\.jpg$", $file_name)) {
>   $file_lost .= " NAME=\"$file_names\">$file_names";
>   }
>  }
>  $file_lost .= " VALUE=\"select\">";
>  closedir($dir);
>
>
> "Michael Virnstein" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > and i'd suggest using eregi instead, because then also .Jpg or .JPG will
> be
> > found.
> >
> > "Michael Virnstein" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > see what's wrong here:
> > > ereg('(^[0-1231]$).jpg$',$file_name)
> > >
> > > [] meens a group of characters, so in your case
> > > 0,1,2 and 3 are valid characters. you haven't defined any
> > > modifer like ?,*,+ or{}, so one of this characters has to
> > > be found exactly one time. you're using ^ outside the [] so it meens
the
> > > beginning of the string.
> > > in your case none of these characters inside the [] can be found at
the
> > > beginning of the string.
> > > then you use $ after the []. $ meens the end of the string. none of
the
> > > characters in the [] matches at the end of the string.
> > > so this would be right:
> > >
> > > ereg('_[0-9]{4}\.jpg$', $file_name);
> > >
> > > so this meens:
> > > the beginning of the string doesn't matter, because we have not
> specified
> > ^
> > > at the beginning.
> > > there has to be an underscore, followed by 4 characters between 0 and
9,
> > > followed by an dot,
> > > followed by j, followd by p, followed by g. g has to be at the end of
> the
> > > string, because of the $.
> > > or you can use:
> > > ereg('^\.*_[0-9]{4}\.jpg$', $file_name);
> > >
> > > this will meen :
> > > any characters at the beginning between 0 and unlimited times, then
> > followed
> > > by an underscore,
> > > followed by 4 characters between 0 and 9, followed by a dot, followed
by
> > > jpg. same as above
> > > though. But the * is a real performance eater so it could be slightly
> > faster
> > > if you're using the first example.
> > >
> > >
> > >
> > > "Jas" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > I hate to say it but that didn't work, I have been trying different
> > > > variations of the same ereg('_(^90-9{4}$).jpg$',$file_names) and
> nothing
> > > > seems to work for me, I have also been looking at the ereg and
> preg_ereg
> > > > functions but they don't seem to make sense to me, here is the code
as
> a
> > > > whole if this helps:
> > > > // query directory and place results in select box
> > > > $dir_name = "/path/to/images/directory/on/server/"; // path to
> directory
> > > on
> > > > server
> > > > $dir = opendir($dir_name); // open the directory in question
> > > > $file_lost .= " > > NAME=\"ad01\">
> > > > ";
> > > >  while ($file_names = readdir($dir)) {
> > > >   if ($file_names != "." && $file_names !=".." &&
> > > ereg('_(^[0-9]{4}.jpg$)',
> > > > $file_names)) // filter my contents
> > > >  {
> > > >   $file_lost .= " > > > NAME=\"$file_names\">$file_names";
> > > >   }
> > > >  }
> > > >  $file_lost .= " NAME=\"submit\"
> > > > VALUE=\"select\">";
> > > >  closedir($dir);
> > > > What I am trying to accomplish is to list the contents of a
directory
> in
> > > > select box but I want to filter out any files that dont meet this
> > criteria
> > > > *_.jpg and nothing is working for me, any help or good tutorials
> on
> > > > strings would be great.
> > > > Jas
> > > > "Erik Price" <[EMAIL PROTECTED]> wrote in message
> > > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > >
> > > > > On Thursday, April 11, 2002, at 05:59  AM, jas wrote:
> > > > >
> > > > > > Is this a correct string to show on

[PHP] Re: String termination with \0 ?

2002-04-11 Thread David Robley

In article <[EMAIL PROTECTED]>, 
[EMAIL PROTECTED] says...
> Hi All,
> 
> I have the following question. I have been developing with C for a
> while and I was used that the \0 indicated the end of a string. So if
> I had a variable containing 1234\056789 and the variable was printed,
> only 1234 was printed.
> 
> As I can see in PHP (version  4.0.6 ), when I echo such a variable
> also the characters are printed, even the characters after \0. Is this
> the case PHP should work or is it a bug ? Isn't \0 really a string
> termination character in PHP ?
> 
> I have been searching for documentation on this matter so if anyone
> could help me...

In this respect, PHP is not like C. Strings are defines within quotes, 
single or double depending on the circumstances. So \0 does not define 
the end of a string.

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

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




[PHP] Re: string reverse ??

2002-04-09 Thread Yuri Petro

strrev -- Reverse a string
http://www.php.net/manual/en/function.strrev.php

--
Kind regards,
Yuri.

 www.AceHoster.com  Quality web hosting

"Scott Fletcher" <[EMAIL PROTECTED]> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:[EMAIL PROTECTED]...
> Hi!
>
> Is there a PHP code or function that would reverse the data in the
> string?
>
> THanks,
>  Scott
>
>



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




[PHP] RE: string conversion

2001-09-21 Thread saif


correct way is to get file name is :

$path_parts = pathinfo($dir.$file);
$fdir = $path_parts["dirname"]; // directory name
$fname = $path_parts["basename"];   // file name
$ftext = $path_parts["extension"];  // file extension



best regards from saif
---
[php 406, apache 1312, winme]
[mysql 32321, personal oracle 8]







_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: String Comparison

2001-07-25 Thread Adrian Ciutureanu

Note that using strings without quotes generates a warning that is not
displayed in the default configuration of PHP. The message looks like
"Warning: Use of undefined constant anyString - assumed 'anyString' in
test.php on line 3"
(line 3: echo anyString;)
If you want to see these warnings, set
error_reporting = E_ALL
instead of
error_reporting = E_ALL & ~E_NOTICE
in php.ini



--- "Jason Bell" <[EMAIL PROTECTED]> wrote

Hello.

I'm trying to compare two strings, and performa function if the are the
same.  Easy right?  I thought so until I tried it...

$query = "select type from images where id=$id";
$result = mysql_query($query);
$type = mysql_result($result,0,"type");
print $type;
if (image/pjpeg == $type) { print "Type is JPG"; };

returned:

image/pjpeg
Warning: Division by zero in /home/daelic/www/photo/mkthumb.php on line 8


Any idea on why this won't work?

Thanks!

Jason




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: string search

2001-07-16 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (J Smith) wrote:

> > I need a search function (if statement) that performs a search on a string
> > and if the string contains something like "aol.com", performs another
> > function. Can anyone help me? Thanks.
> > 
> > Joseph
> > 
> 
> Try researching regular expressions. In PHP, look at the preg and ereg 
> groups of functions.

This doesn't sound like it requires the overhead of a regex function.  
Check out  instead.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] RE: string search

2001-07-16 Thread scott [gts]

hehe... that's what regular expressions are for.
they're extrememly powerful... but that doesnt mean that
you should only use them for extremely complicated situations.
they work great everywhere... 

if you dont like "overdoing it", you might as well loop
thru the string character by character, C-style.  :-)

> -Original Message-
> From: Sheridan Saint-Michel [mailto:[EMAIL PROTECTED]]
> Subject: Re: [PHP] RE: string search
> 
> Couldn't he just do something like
> 
> if (strstr($text, "aol.com")) {
>MyFunction();
> } else {
>echo "Not Found";
> }
> 
> It just seems like using ereg for this is like killing a fly with a
> sledgehammer
> 
> Sheridan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] RE: string search

2001-07-16 Thread Sheridan Saint-Michel

Couldn't he just do something like

if (strstr($text, "aol.com")) {
   MyFunction();
} else {
   echo "Not Found";
}

It just seems like using ereg for this is like killing a fly with a
sledgehammer

Sheridan

- Original Message -
From: scott [gts] <[EMAIL PROTECTED]>
To: php <[EMAIL PROTECTED]>
Sent: Monday, July 16, 2001 10:59 AM
Subject: RE: [PHP] RE: string search


> read the docs for ereg... i hardly use it, so i dont know
> for certain if it will match. (althouth the use of "^" at
> beginning *and* end suggests that it wont do what you expect)
>
> preg will match "aol.com" with this regexp:
>
> preg_match('/aol.com/', $string )
>
>
> > -Original Message-
> > From: Joseph Bannon [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, July 16, 2001 11:49 AM
> > To: PHP (E-mail)
> > Subject: [PHP] RE: string search
> >
> >
> > Will this work?
> >
> > $string = "http://www.aol.com/";;
> >
> > if (ereg ("^aol.com^", $string) {
> > }
> > else {
> > }
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] RE: string search

2001-07-16 Thread scott [gts]

read the docs for ereg... i hardly use it, so i dont know
for certain if it will match. (althouth the use of "^" at
beginning *and* end suggests that it wont do what you expect)

preg will match "aol.com" with this regexp:

preg_match('/aol.com/', $string )


> -Original Message-
> From: Joseph Bannon [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 16, 2001 11:49 AM
> To: PHP (E-mail)
> Subject: [PHP] RE: string search
> 
> 
> Will this work?
> 
> $string = "http://www.aol.com/";;
> 
> if (ereg ("^aol.com^", $string) {
> }
> else {
> }


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] RE: string search

2001-07-16 Thread Joseph Bannon

Will this work?

$string = "http://www.aol.com/";;

if (ereg ("^aol.com^", $string) {
}
else {
}



> I need a search function (if statement) that performs a search on a string
> and if the string contains something like "aol.com", performs another
> function. Can anyone help me? Thanks.
















-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: string search

2001-07-16 Thread Steve Brett

have a look at ereg() (regular expression match)  functions in manual.
they'll do exactly what you want.

Steve

"Joseph Bannon" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I need a search function (if statement) that performs a search on a string
> and if the string contains something like "aol.com", performs another
> function. Can anyone help me? Thanks.
>
> Joseph



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: string search

2001-07-16 Thread J Smith

Joseph Bannon wrote:

> I need a search function (if statement) that performs a search on a string
> and if the string contains something like "aol.com", performs another
> function. Can anyone help me? Thanks.
> 
> Joseph
> 

Try researching regular expressions. In PHP, look at the preg and ereg 
groups of functions.

J

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Re: string formatting help

2001-07-06 Thread Chad Day

Yeah, I was seeing them.  And when I stripped them out and replaced them
with white space, it still broke in those places, it'd look like:

kdjsakdasja

dsakjaskjsa


dsakaskj

But I got it fixed..

$RESPONSE = addslashes($row[RESPONSE]);
$OVERLIBBED = str_replace(chr(13), "", $RESPONSE);
$OVERLIBBED = str_replace(chr(10), "", $OVERLIBBED);

is what worked for me ..

Thanks all,
Chad

-Original Message-
From: Steve Edberg [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 06, 2001 4:29 PM
To: Chad Day; [EMAIL PROTECTED]
Subject: [PHP] Re: string formatting help


In the original message below, did you mean that you're actually
SEEING the  tags in the output? If so, there may be a conversion
with htmlentities() going on somewhere that converts the  tags to
<br> (so they are displayed instead of being interpreted).

If you replaced the 's with spaces or newlines, the output
_should_ all be on one line, since HTML considers ALL strings of
whitespace (tabs, newlines, returns, spaces) to be a single space. If
you replaced 's with newlines and you are getting the line breaks
still, your output may be in a ... block.

- steve


At 3:36 PM -0300 7/6/01, "InÈrcia Sensorial" <[EMAIL PROTECTED]> wrote:
>   Maybe:
>
>$array = explode("", $string);
>
>foreach ($array as $key => $value) {
> echo "$value";
>}
>
>   Would separate the string by 's and print all in one line.
>


Or, more compactly:

echo str_replace('', '', $string);

This would only work if tags were lowercased; to handle mixed case,
you'd need to do

echo eregi_replace('', '', $string);

or use the preg equivalent




>   Julio Nobrega.
>
>A hora est· chegando:
>http://sourceforge.net/projects/toca
>
>"Chad Day" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>>  I'm trying to pull a string from a database to use in a javascript
>>  function.. but it's doing line breaks on me, which in turn messes up the
>>  javascript.
>>
>>  The string in the mysql db is like:
>>  kjdsakjadkskjdkskjkdfjdfkjfd
>>
>>  When I pull it out, it becomes:
>>
>>  kjdsakjadk
>>  
>>  skjdks
>>  
>>  
>>  kjkdfjdfkjfd
>>
>>  I've tried replacing the br's with blank spaces or new line characters,
>but
>>  in the html code it still breaks on those breaks when I echo it back
out.
>>  How can I force this string to be all on one line?
>>
>>  Thanks,
>  > Chad
>>

--
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: string formatting help

2001-07-06 Thread Steve Edberg

In the original message below, did you mean that you're actually
SEEING the  tags in the output? If so, there may be a conversion
with htmlentities() going on somewhere that converts the  tags to

(so they are displayed instead of being interpreted). If you replaced the 's with spaces or newlines, the output _should_ all be on one line, since HTML considers ALL strings of whitespace (tabs, newlines, returns, spaces) to be a single space. If you replaced 's with newlines and you are getting the line breaks still, your output may be in a ... block. - steve At 3:36 PM -0300 7/6/01, "InÈrcia Sensorial" <[EMAIL PROTECTED]> wrote: > Maybe: > >$array = explode("", $string); > >foreach ($array as $key => $value) { > echo "$value"; >} > > Would separate the string by 's and print all in one line. > Or, more compactly: echo str_replace('', '', $string); This would only work if tags were lowercased; to handle mixed case, you'd need to do echo eregi_replace('', '', $string); or use the preg equivalent > Julio Nobrega. > >A hora est· chegando: >http://sourceforge.net/projects/toca > >"Chad Day" <[EMAIL PROTECTED]> wrote in message >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... >> I'm trying to pull a string from a database to use in a javascript >> function.. but it's doing line breaks on me, which in turn messes up the >> javascript. >> >> The string in the mysql db is like: >> kjdsakjadkskjdkskjkdfjdfkjfd >> >> When I pull it out, it becomes: >> >> kjdsakjadk >> >> skjdks >> >> >> kjkdfjdfkjfd >> >> I've tried replacing the br's with blank spaces or new line characters, >but >> in the html code it still breaks on those breaks when I echo it back out. >> How can I force this string to be all on one line? >> >> Thanks, > > Chad >> -- +-- Factoid: Of the 100 largest economies in the world, 51 are --+ | Steve Edberg University of California, Davis | | [EMAIL PROTECTED] Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]

[PHP] Re: string formatting help

2001-07-06 Thread Inércia Sensorial

  Maybe:

$array = explode("", $string);

foreach ($array as $key => $value) {
echo "$value";
}

  Would separate the string by 's and print all in one line.


--


  Julio Nobrega.

A hora está chegando:
http://sourceforge.net/projects/toca

"Chad Day" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I'm trying to pull a string from a database to use in a javascript
> function.. but it's doing line breaks on me, which in turn messes up the
> javascript.
>
> The string in the mysql db is like:
> kjdsakjadkskjdkskjkdfjdfkjfd
>
> When I pull it out, it becomes:
>
> kjdsakjadk
> 
> skjdks
> 
> 
> kjkdfjdfkjfd
>
> I've tried replacing the br's with blank spaces or new line characters,
but
> in the html code it still breaks on those breaks when I echo it back out.
> How can I force this string to be all on one line?
>
> Thanks,
> Chad
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]