Bluehost.com Web Hosting $6.95

Question about an array

This is a discussion on Question about an array within the PHP General forums, part of the PHP Programming Forums category; I want to create an array with some text. Let's say the following: $sometext = array(explode(" ", "...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-03-2004
Vernon
 
Posts: n/a
Default Question about an array

I want to create an array with some text. Let's say the following:

$sometext = array(explode(" ", "Objective: Position as a Machine Attendant
and or Operator Summary - Over 16 years experience in packaging and
maintenance of various operating machinery. - 13 years experience in cutting
steel and operating a steel press. - Part time experience in packaging and
shipping bread for a bakery."));

I can easily return that text using:

print_r($sometext);

However I want loop through that text for to bold certain words in the
array. In any event I've tried using the following but it only returns
"sometext at[0] is: [Array]" which is not want I want, I want it to show me
each word in the array through the loop. Any ideas what I am doing wrong?

$arrayLength = count($sometext);

for ($i = 0; $i < $arrayLength; $i++){
echo "sometext at[" . $i . "] is: [" .$sometext[$i] . "]<br>\n";
}

Thanks
Reply With Quote
  #2 (permalink)  
Old 01-03-2004
Adrian Teasdale
 
Posts: n/a
Default Piping email

Is it possible to pipe email directly to PHP like it's possible to do
with perl? I need to do this using Exim which I'm also unfamiliar with
so if anyone has done this I'd appreciate knowing how! :)

Thanks

Ade
Reply With Quote
  #3 (permalink)  
Old 01-04-2004
Matt Grimm
 
Posts: n/a
Default Re: Question about an array

If you're going to build your array that way, then you need to loop through
$sometext[0], not $sometext. You're creating an array in the first element
of the $sometext array, so $sometext element zero is an array containing
your exploded words.

Instead, try:

$sometext = explode(" ", "your long string");

--
Matt Grimm
Web Developer
The Health TV Channel, Inc.
(a non - profit organization)
3820 Lake Otis Parkway
Anchorage, AK 99508
907.770.6200 ext. 686
907.336.6205 (fax)
E-mail: mgrimm@healthtvchannel.org
Web: www.healthtvchannel.org

"Vernon" <vernon@comp-wiz.com> wrote in message
news:20040103221149.33002.qmail@pb1.pair.com...
> I want to create an array with some text. Let's say the following:
>
> $sometext = array(explode(" ", "Objective: Position as a Machine Attendant
> and or Operator Summary - Over 16 years experience in packaging and
> maintenance of various operating machinery. - 13 years experience in

cutting
> steel and operating a steel press. - Part time experience in packaging and
> shipping bread for a bakery."));
>
> I can easily return that text using:
>
> print_r($sometext);
>
> However I want loop through that text for to bold certain words in the
> array. In any event I've tried using the following but it only returns
> "sometext at[0] is: [Array]" which is not want I want, I want it to show

me
> each word in the array through the loop. Any ideas what I am doing wrong?
>
> $arrayLength = count($sometext);
>
> for ($i = 0; $i < $arrayLength; $i++){
> echo "sometext at[" . $i . "] is: [" .$sometext[$i] . "]<br>\n";
> }
>
> Thanks

Reply With Quote
  #4 (permalink)  
Old 01-05-2004
David T-G
 
Posts: n/a
Default Re: [PHP] Piping email

Adrian --

You have started a new thread by taking an existing message and replying to
it while merely changing the Subject: line.

That is bad, because it breaks threading. Whenever you reply to a message,
your mail client generates a "References:" header that tells all recipients
to which posting(s) your posting refers. A mail client uses this information
to build a "thread tree" of the postings so that it is easy to see just how
they relate to each other.

With your posting style you successfully torpedoed this useful feature; your
posting shows up within an existing thread even though it is completely
unrelated.

Always do a fresh post when you want to start a new thread. That means that
you do not select any sort of "Reply" when you start your message. You can
save the list address in your address book (or equivalent) for convenience.

...and then Adrian Teasdale said...
%
% Is it possible to pipe email directly to PHP like it's possible to do

Yes.


% with perl? I need to do this using Exim which I'm also unfamiliar with
% so if anyone has done this I'd appreciate knowing how! :)

It's the same thing as for piping email to anything. I don't know exim
from anything else, but I'd use the .forward file no matter what MTA is
installed.


%
% Thanks
%
% Ade


HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtg@justpickone.org * society and not sufficient moral courage.
(work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/+Jy9Gb7uCXufRwARAn72AKDU8rvnhDV4fV+W4ErBDfgn/eozHQCg6KZs
+Qgj0aifpfetByBeFIf+cKg=
=WjU9
-----END PGP SIGNATURE-----

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:52 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0