[PHP] String Question

2004-05-02 Thread Dave Carrera
Hi List,

How would I show 100 chars after finding the first instance of a searched
word in a string.

So I have a string of which I search for the first instance of hello and
display from there 100 more chars.

My output word then be something like:

 hello and show the next 100 chars...

Thank you in advance for any help or advice given.

Dave C

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004
 

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



Re: [PHP] String Question

2004-05-02 Thread John W. Holmes
Dave Carrera wrote:
How would I show 100 chars after finding the first instance of a searched
word in a string.
$start = strpos('hello',$str);
$hundredchars = substr($str,$start,100);
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


[PHP] string question

2003-06-11 Thread Mukta Telang
Hi,
if a string is:
$x=A.B. XYZ;
and if I post it as a hidden form control and echo $_POST['x'] then I
get:
A.B.
and not A.B. XYZ !
What should I do?
Mukta

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



RE: [PHP] string question

2003-06-11 Thread John W. Holmes
 if a string is:
   $x=A.B. XYZ;
 and if I post it as a hidden form control and echo $_POST['x'] then I
 get:
   A.B.
 and not A.B. XYZ !
 What should I do?

Learn HTML. Use quotes around your attribute values:

input type=hidden name=foo value=A.B. XYZ

---John W. Holmes...

Amazon Wishlist: http://www.amazon.com/o/registry/3BEXC84AB3A5E

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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



Re: [PHP] string question

2003-06-11 Thread Chris Hayes
At 16:42 11-6-03, you wrote:
if a string is:
$x=A.B. XYZ;
and if I post it as a hidden form control and echo $_POST['x'] then I
get:
A.B.
and not A.B. XYZ !
What should I do?
how do you assign the value to the hidden form element?

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


Re: [PHP] string question

2003-06-11 Thread Brian V Bonini
On Wed, 2003-06-11 at 10:42, Mukta Telang wrote:
 Hi,
 if a string is:
   $x=A.B. XYZ;
 and if I post it as a hidden form control and echo $_POST['x'] then I
 get:
   A.B.
 and not A.B. XYZ !
 What should I do?
 Mukta

$x = 'A.B. XYZ';


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



Re: [PHP] string question

2003-06-11 Thread Leif K-Brooks
Put quotes around the value attribute of your input tag, for example 
input type=hidden name=x value=A.B. XYZ /

Mukta Telang wrote:

Hi,
if a string is:
$x=A.B. XYZ;
and if I post it as a hidden form control and echo $_POST['x'] then I
get:
A.B.
and not A.B. XYZ !
What should I do?
Mukta
 

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


RE: [PHP] String Question

2002-08-01 Thread Tim Ward

or ...
while($new = substr($old, $i++ * $strlen, $strlen)) $array[] = $new;


Tim Ward
www.chessish.com 

 -Original Message-
 From: Richard Baskett [mailto:[EMAIL PROTECTED]]
 Sent: 31 July 2002 20:47
 To: Randy Johnson; PHP General
 Subject: Re: [PHP] String Question
 
 
 ?
 $string = 'abcdefghijklmnopqrstuvwxyz';
 $strNum = ceil(strlen($string)/8);
 
 for ($i=0; $i$strNum; $i++) $newString[] = substr($string, 
 ($i*8), 8);
 
 for ($j=0; $jcount($newString); $j++) echo string$j = 
 $newString[$j]br
 /;
 ?
 
 Rick
 
 A sense of humor can help you over look the unattractive, tolerate the
 unpleasant, cope with the unexpected, and smile through the 
 unbearable. -
 Moshe Waldoks
 
  From: Randy Johnson [EMAIL PROTECTED]
  Date: Wed, 31 Jul 2002 15:26:15 -0400
  To: [EMAIL PROTECTED]
  Subject: [PHP] String Question
  
  Hello,
  
  I would like to be able to do the following but have not 
 figured out a way to
  handle it
  
  $string=abcdefghijklmnopqrstuvwxz;
  
  I would like to divde the above string into separate 
 strings 8 charactes long
  , example
  
  $string1=abcdefgh
  $string2=ijklmnop
  $string3=qrstuvwx
  $string4=yz
  
  if the string were only 10 long
  
  $string=abcdefghij
  
  then
  
  $string1=abcdefgh
  $string2=ij
  
  any suggestions would be greatly appreciated.
  
  Thanks,
  
  
  Randy
  
 
 

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




[PHP] String Question

2002-07-31 Thread Randy Johnson

Hello,

I would like to be able to do the following but have not figured out a way to handle it

$string=abcdefghijklmnopqrstuvwxz;

I would like to divde the above string into separate strings 8 charactes long , example

$string1=abcdefgh
$string2=ijklmnop
$string3=qrstuvwx
$string4=yz

if the string were only 10 long

$string=abcdefghij

then

$string1=abcdefgh
$string2=ij

any suggestions would be greatly appreciated.

Thanks,


Randy



Re: [PHP] String Question

2002-07-31 Thread Martin Clifford

Give this a whirl:

?php

$string = abcdefghijklmnopqrstuvwxyz;
$len = strlen($string)  // in this case, 26

for($i=0; $i  $len; $i+8) {
   $str_array[] = substr($string, $i, 8);
}

for($i=0; $i  count($str_array); $i++) {
   echo $str_array[$i] . br\n;
}

?

I haven't tested it, but in theory it should find the length of the string (26), loop 
through it as long as $i is less than 26, incrementing 8 at a time.  Each time it goes 
through, $str_array[] is fed a new element, which is a substring of $string that 
starts at $i (0, 8, 16, 24, etc) and grabs 8 characters.  So here is how the data 
should be retrieved.

1st loop:  0-7 (8 elements)
2nd loop:  8-15 (8 elements)
3rd loop:  16-23 (8 elements)
4th loop:  24-26 (3 elements)

Let me know how it works out for you :o)

Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/


 Randy Johnson [EMAIL PROTECTED] 07/31/02 03:26PM 
Hello,

I would like to be able to do the following but have not figured out a way to handle it

$string=abcdefghijklmnopqrstuvwxz;

I would like to divde the above string into separate strings 8 charactes long , example

$string1=abcdefgh
$string2=ijklmnop
$string3=qrstuvwx
$string4=yz

if the string were only 10 long

$string=abcdefghij

then

$string1=abcdefgh
$string2=ij

any suggestions would be greatly appreciated.

Thanks,


Randy


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




Re: [PHP] String Question

2002-07-31 Thread Richard Baskett

?
$string = 'abcdefghijklmnopqrstuvwxyz';
$strNum = ceil(strlen($string)/8);

for ($i=0; $i$strNum; $i++) $newString[] = substr($string, ($i*8), 8);

for ($j=0; $jcount($newString); $j++) echo string$j = $newString[$j]br
/;
?

Rick

A sense of humor can help you over look the unattractive, tolerate the
unpleasant, cope with the unexpected, and smile through the unbearable. -
Moshe Waldoks

 From: Randy Johnson [EMAIL PROTECTED]
 Date: Wed, 31 Jul 2002 15:26:15 -0400
 To: [EMAIL PROTECTED]
 Subject: [PHP] String Question
 
 Hello,
 
 I would like to be able to do the following but have not figured out a way to
 handle it
 
 $string=abcdefghijklmnopqrstuvwxz;
 
 I would like to divde the above string into separate strings 8 charactes long
 , example
 
 $string1=abcdefgh
 $string2=ijklmnop
 $string3=qrstuvwx
 $string4=yz
 
 if the string were only 10 long
 
 $string=abcdefghij
 
 then
 
 $string1=abcdefgh
 $string2=ij
 
 any suggestions would be greatly appreciated.
 
 Thanks,
 
 
 Randy
 


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




Re: [PHP] String Question

2002-07-31 Thread J.F.Kishor

Hi Randy,

 Just copy the following code and execute it, it works as you
require, tested works fine.

?
$string=abcdefghijklmnopqrstuvwxyz;
$length = strlen($string);  // Finds the length of the string
$octFull = round($length/8);// splits the length and finds how many
// times 8 occurs in the length
$intStart=0; //initilize the integer start to divided the string into 8's
// Loop to divide the $string into 8 and print them.
for($i =1;$i  $octFull+2;$i++)
{
  //gets the substring of the string with the length of 8
  $strDiv[$i] = substr($string,$intStart,8);

  //increment the start position to take the next 8 among the string
  $intStart = ($intStart+8);

  echo pstring$i : $strDiv[$i]/p;
}
?



- JFK
kishor
Nilgiri Networks





On Wed, 31 Jul 2002, Randy Johnson wrote:

 Hello,
 
 I would like to be able to do the following but have not figured out a way to handle 
it
 
 $string=abcdefghijklmnopqrstuvwxz;
 
 I would like to divde the above string into separate strings 8 charactes long , 
example
 
 $string1=abcdefgh
 $string2=ijklmnop
 $string3=qrstuvwx
 $string4=yz
 
 if the string were only 10 long
 
 $string=abcdefghij
 
 then
 
 $string1=abcdefgh
 $string2=ij
 
 any suggestions would be greatly appreciated.
 
 Thanks,
 
 
 Randy
 


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




Re: [PHP] string question

2001-02-23 Thread Philip Olson


Use number_format() :

http://www.php.net/manual/en/function.number-format.php

echo number_format($number);

Other options exist with this function, it's pretty useful.  


Regards

Philip Olson
http://www.cornado.com/

On Fri, 23 Feb 2001 [EMAIL PROTECTED] wrote:

 I have a string that contains a number such as: $string = '12345'
 
 I want that to read 12,345 though.  Is there any way in which I can insert a 
 comma in there in the correct places?
 
 -Matt
 


--
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] string question

2001-02-23 Thread PHPBeginner.com

check out php.net/number-format


Sincerely,

 Maxim Maletsky
 Founder, Chief Developer

 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 24, 2001 4:53 AM
To: [EMAIL PROTECTED]
Subject: [PHP] string question


I have a string that contains a number such as: $string = '12345'

I want that to read 12,345 though. Is there any way in which I can insert a
comma in there in the correct places?

-Matt


-- 
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]