Re: [PHP] Easy question - delete strings from the beginning of space...

2005-09-20 Thread Jochem Maas

Gustav Wiberg wrote:

Hi there!

I guess this is an easy question. I have string...

Hello you

and I want to get the Hello part.

How do I do that? (I can of course search for first occurence of space 
and then use substr, but I guess there is an easier solution?


how much easier do you want it? oh and guessing kinda sucks.

$str = Hello World;
$words = explode( , $str);
echo $words[0];

... but what if you have double spaces, or a space at the beginning?



/G
http://www.varupiraten.se/



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



Re: [PHP] Easy question - delete strings from the beginning of space...

2005-09-20 Thread Gustav Wiberg
- Original Message - 
From: Jochem Maas [EMAIL PROTECTED]

To: Gustav Wiberg [EMAIL PROTECTED]
Cc: PHP General php-general@lists.php.net
Sent: Tuesday, September 20, 2005 2:24 PM
Subject: Re: [PHP] Easy question - delete strings from the beginning of 
space...




Gustav Wiberg wrote:

Hi there!

I guess this is an easy question. I have string...

Hello you

and I want to get the Hello part.

How do I do that? (I can of course search for first occurence of space 
and then use substr, but I guess there is an easier solution?


how much easier do you want it? oh and guessing kinda sucks.

$str = Hello World;
$words = explode( , $str);
echo $words[0];

... but what if you have double spaces, or a space at the beginning?



/G
http://www.varupiraten.se/





--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.3/106 - Release Date: 2005-09-19



Hi there!

Ok, I'll think I do it in my way because of double spaces etc...

Thanx anyway!

/G
http://www.varupiraten.se/
ps. Forgive me for guessing... :-)

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



Re: [PHP] Easy question - delete strings from the beginning of space...

2005-09-20 Thread Jordan Miller

to get rid of potential double spaces after the explode, you could do:
foreach ($words as $word) {
if (!empty($word)) {
$first = $word;
break;
}
}
echo $first;

This will always return the first word.

Jordan



On Sep 20, 2005, at 7:24 AM, Jochem Maas wrote:


how much easier do you want it? oh and guessing kinda sucks.

$str = Hello World;
$words = explode( , $str);
echo $words[0];

... but what if you have double spaces, or a space at the beginning?



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



RE: [PHP] Easy Question (I think)

2004-08-03 Thread Richard Bewley
Are you looking for the round function?

$number = 4.3392;
$number = round($number);

-
Thank you,
Richard Bewley
[EMAIL PROTECTED]
 
Equinox Systems and Development
Website: http://www.eq-dev.com/ 
 
Also, please look at our webhosting services, specializing in business web
hosting starting from $15 per month!
 

-Original Message-
From: Robert Frame [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 03, 2004 11:25 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Easy Question (I think)

I am sure this is an obvious answer, but dang if I could find it.

How do you chop off a decimal value in PHP?  I know I can do it using a
combination of modulus, subtraction and division, but isn't there a function
that does this?  I think I am suffering from a giant mental block =)

-- 
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] Easy Question (I think)

2004-08-03 Thread Robert Cummings
On Tue, 2004-08-03 at 23:25, Robert Frame wrote:
 I am sure this is an obvious answer, but dang if I could find it.
 
 How do you chop off a decimal value in PHP?  I know I can do it using a
 combination of modulus, subtraction and division, but isn't there a function
 that does this?  I think I am suffering from a giant mental block =)

floor()

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



Re: [PHP] Easy Question -- Show/ Hide text based on output of query

2002-02-05 Thread Jason Wong

On Wednesday 06 February 2002 00:03, Edward R. Bailey wrote:
 Hi,

 I am working on a page the displays the output of a query in a table and
 I only want to show the field labels that have corresponding output from
 the database. I am only really concerned with the last label in the
 table.

 The label is called Notes and the corresponding field in the database
 is memberNotes

 So I wrote the following script where I think I am saying if memberNotes
 returns any value then print the output of $notes in the table cell
 where it is called, but nothing happens and the output of $notes is not
 displayed regardless whether memberNotes has any output.

 ?php If ($memberNotes =='1') {

What is $memberNotes supposed to contain? If it is supposed to contain notes 
on members then surely it can't be '1' all the time?

I think you probably want:

  if ($memberNotes) { ...



hth
-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Where is John Carson now that we need him?
-- RLG
*/

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




Re: [PHP] Easy Question -- Show/ Hide text based on output of query

2002-02-05 Thread Jason Wong

On Wednesday 06 February 2002 02:14, Edward R. Bailey wrote:

Please keep the discussion on the list!

 Thanks for responding! Yes the memberNotes database field only
 contains information in about a third of the records so I wanted to hide
 the entire field and label when their was no relevent data.

 I made the change you suggested, but the field label does not show up
 when memberNotes contains data. As follows is the current script. Is
 what what you suggested?


 ?php If ($memberNotes) {
 $notes = div align=\/left\/font
 size=\/-1\/bNotes:/b/font/div;
   } else {
 $notes = div align=\/left\/font
 size=\/-1\/b/b/font/div;
   }
 ?

What are those forward slashes (/) doing in $notes? Try getting rid of them, 
they don't look very HTML to me :)

Also try echo($notes) OUTSIDE of a table construct to see what it contains.


hth
-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Q:  What do Winnie the Pooh and John the Baptist have in common?
A:  The same middle name.
*/

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




RE: [PHP] Easy Question -- Show/ Hide text based on output of query

2002-02-05 Thread Edward R. Bailey

I used echo($notes) at the bottom of the page and the output of $notes
prints reardless of whether or not the db field $memberNotes contains
any data. It seems to me that $notes is always acting as if $memberNotes
always contains data. Is their some way to invoke $notes only if
$memberNotes returns any data?

Thanks for your help,
ED



 -Original Message-
 From: Jason Wong [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, February 05, 2002 1:22 PM
 To: PHP General Mailing List
 Subject: Re: [PHP] Easy Question -- Show/ Hide text based on 
 output of query
 
 
 On Wednesday 06 February 2002 02:14, Edward R. Bailey wrote:
 
 Please keep the discussion on the list!
 
  Thanks for responding! Yes the memberNotes database field only 
  contains information in about a third of the records so I wanted to 
  hide the entire field and label when their was no relevent data.
 
  I made the change you suggested, but the field label does 
 not show up 
  when memberNotes contains data. As follows is the current 
 script. Is 
  what what you suggested?
 
 
  ?php If ($memberNotes) {
  $notes = div align=\/left\/font 
  size=\/-1\/bNotes:/b/font/div;
} else {
  $notes = div align=\/left\/font 
  size=\/-1\/b/b/font/div;
}
  ?
 
 What are those forward slashes (/) doing in $notes? Try 
 getting rid of them, 
 they don't look very HTML to me :)
 
 Also try echo($notes) OUTSIDE of a table construct to see 
 what it contains.
 
 
 hth
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 
 /*
 Q:What do Winnie the Pooh and John the Baptist have in common?
 A:The same middle name.
 */
 
 -- 
 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] Easy Question -- Show/ Hide text based on output of query

2002-02-05 Thread Jason Wong

On Wednesday 06 February 2002 02:38, Edward R. Bailey wrote:
 I used echo($notes) at the bottom of the page and the output of $notes
 prints reardless of whether or not the db field $memberNotes contains
 any data. It seems to me that $notes is always acting as if $memberNotes
 always contains data. Is their some way to invoke $notes only if
 $memberNotes returns any data?


Please post your full code.


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
I go on working for the same reason a hen goes on laying eggs.
- H. L. Mencken
*/

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




RE: [PHP] Easy Question -- Show/ Hide text based on output of query

2002-02-05 Thread Edward R. Bailey

Sorry -- Here it is


 ?php If ($memberNotes) {
 $notes = div align=leftfont
size=-1bNotes:/b/font/div;
   } else {
 $notes = ;
   }
 ?

Then I call $notes using --

echo ($notes)

 -Original Message-
 From: Jason Wong [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, February 05, 2002 1:39 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] Easy Question -- Show/ Hide text based on 
 output of query
 
 
 On Wednesday 06 February 2002 02:38, Edward R. Bailey wrote:
  I used echo($notes) at the bottom of the page and the 
 output of $notes 
  prints reardless of whether or not the db field 
 $memberNotes contains 
  any data. It seems to me that $notes is always acting as if 
  $memberNotes always contains data. Is their some way to 
 invoke $notes 
  only if $memberNotes returns any data?
 
 
 Please post your full code.
 
 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 
 /*
 I go on working for the same reason a hen goes on laying eggs.
 - H. L. Mencken
 */
 
 -- 
 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] Easy Question -- Show/ Hide text based on output of query

2002-02-05 Thread Jason Wong

On Wednesday 06 February 2002 02:53, Edward R. Bailey wrote:
 Sorry -- Here it is


  ?php If ($memberNotes) {
  $notes = div align=leftfont
 size=-1bNotes:/b/font/div;
} else {
  $notes = ;
}
  ?

 Then I call $notes using --

 echo ($notes)

I meant your *whole* script -- never mind, have you tried echo($memberNotes) 
to see what that contains? Are you sure it doesn't contain spaces or other 
non-visible characters?


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
All language designers are arrogant.  Goes with the territory...
(By Larry Wall)
*/

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




RE: [PHP] Easy Question -- Show/ Hide text based on output of query

2002-02-05 Thread Edward R. Bailey

Thanks for all your help, but I figured out what I did wrong

I was calling the memberNotes field using

 echo $get_detail-Fields(memberNotes) 

so when I replaced $memberNotes in the script with
$get_detail-Fields(memberNotes) it worked like a charm

 If ($get_detail-Fields(memberNotes)) {
 $notes = div align=leftfont
size=-1bNotes:/b/font/div;
} else {
 $notes = ;
}

Dumb error on my part. 

Thank you very much for your patience,

Ed


 -Original Message-
 From: Jason Wong [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, February 05, 2002 1:53 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] Easy Question -- Show/ Hide text based on 
 output of query
 
 
 On Wednesday 06 February 2002 02:53, Edward R. Bailey wrote:
  Sorry -- Here it is
 
 
   ?php If ($memberNotes) {
   $notes = div align=leftfont 
  size=-1bNotes:/b/font/div;
 } else {
   $notes = ;
 }
   ?
 
  Then I call $notes using --
 
  echo ($notes)
 
 I meant your *whole* script -- never mind, have you tried 
 echo($memberNotes) 
 to see what that contains? Are you sure it doesn't contain 
 spaces or other 
 non-visible characters?
 
 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 
 /*
 All language designers are arrogant.  Goes with the 
 territory... (By Larry Wall) */
 
 -- 
 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] Easy Question

2001-10-05 Thread Maxim Maletsky \(PHPBeginner.com\)


 When you write a php script to access a database,edit 
 records, etc., is the entire thing 1 giant PHP page or a 
 bunch of different ones?  

A giant one

If it can be written both ways, 
 which is the better way to do it?

Depends how big is your 'giant'.

It is all about your coding style, but it is advisable not getting over
500 lines - saves you a lot of developing time.
However, too many (7, 10, more) includes will become noticeable.

Not all is said by this, there are so many reasons why use this or that,
but generally it is up to your own coding style.


Maxim Maletsky
www.PHPBeginner.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]




RE: [PHP] Easy Question

2001-10-05 Thread Richard Heyes

 When you write a php script to access a database,edit records,
 etc., is the
 entire thing 1 giant PHP page or a bunch of different ones?  If it can be
 written both ways, which is the better way to do it?

Using seperate files eases code maintenance and prevents parsing of
redundant code.

--
Richard Heyes
I know not with what weapons World War III will be fought, but World War IV
will be fought with sticks and stones. - Albert Einstein


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

2001-10-05 Thread Don Read


On 06-Oct-2001 Chip wrote:
 When you write a php script to access a database,edit records, etc., is the
 entire thing 1 giant PHP page or a bunch of different ones?  If it can be
 written both ways, which is the better way to do it?
 

I tend to write based on function:

userland.php
adminland.php
whatever ...

then include() the bits where the $vars indicate:

if ($do_detail) 
include('detail.php');

And, of course, underneath is the common thingys:
require(class.html.php);
require(class.forms.php);
require(libsql.php);

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It is necessary for me to learn from others' mistakes. I 
   will not live long enough to make them all by myself.

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

2001-10-05 Thread Joel Ricker

My Database functions are all wrapped up in an easy to use class.  The
methods look something like this:

$db = new DB;
$q = SELECT * FROM ATable;
$db-query($q);
while ($db-next_record()) {
 $db-p(SomethingOrOther);
}

For the PHP script itself, the content management system I wrote up uses
case statements in a single file engine and multple includes.

for example:

switch($func) {
case(news):
 include(/news/news.inc);
 break;
}

and news.inc may contain:

switch($task) {
case(add):
include(/news/news.add.inc);
   break;
case(del):
include(/news/news.del.inc);
   break;
   default:
   include(/news/news.view.inc);
}

and then each would contain the actual code.  It worked really well for a
couple of reasons.  For starts all the includes started as requires for
testing purposes.  If I edited several files but maybe didn't test them all,
it'll will kick out any parse errors or warnings -- also useful since I've
got another person working with me.  Then when the site went live, I changed
them to includes (well actually had to change a bunch of them part way
through when I ran out of memory *s*).

Also the code is very modular.  I know what each file does and so does my
partner who isn't a php programmer but may need to edit the HTML portions a
little. Each file is clearly named as its its funciton so he knows where to
look if there is a problem with a pages appearance.

Joel



-- 
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] Easy question...grabbing variables...

2001-07-11 Thread Sam Masiello


If you want to pass more than one variable via GET, you need to use an
ampersand () character for the variables after the first one (still using a
question mark for the first).

So in your case, you can have this:

http://wwbl.hyrum.net/send_email.php?to=4from=25

Then within your send_email.php script, you can access $from which will have
the value 25 upon entry to your script.

HTH

Sam Masiello
Software Quality Assurance Engineer
Synacor
(716) 853-1362 x289
[EMAIL PROTECTED]

 -Original Message-
From:   Jeff Lewis [mailto:[EMAIL PROTECTED]]
Sent:   Wednesday, July 11, 2001 10:22 AM
To: [EMAIL PROTECTED]
Subject:[PHP] Easy question...grabbing variables...

Um, been using PHP for awhile now and don' even know how to grab these:

http://wwbl.hyrum.net/send_email.php?to=4;from=25

I have usually only passed one variable before so all I've need to do is
$toID=$to but how do I get from?  I know I should know this but I am either
having a major brain fart or missed this in PHP 101 ;)

Jeff


-- 
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] easy question.

2001-01-24 Thread Steven Deaton

the only thing I can think of, would be to eliminate the () around
$fname, $lname, and $email
if they all test true in the first place, the () are kinda obsolete. :)



Nathan Cook wrote:
 
 I have always wrote code this like:
 
 if(($fname)  ($lname)  ($email))
   {  echo "test"; }
 
 Is there an easier way to write the IF line?
 
 Thank You
 
 .:: Nathan Cook [ [EMAIL PROTECTED] ] ::.
 Systems  Network Administrator :: Programmer
 [ phone - 208.343.3110 ][ pager - 208.387.9983 ]
 
 --
 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] easy question.

2001-01-24 Thread Alex Black

if(($fname)  ($lname)  ($email))
{  echo "test"; }
 
 Is there an easier way to write the IF line?

if (isset($fname)  isset($lname)  isset($email)) {
echo "test";
}

I believe the parens in your code don't do anything. anyway, best o' my
knowledge that's the way to do it.

"_)

-a


 Thank You
 
 .:: Nathan Cook [ [EMAIL PROTECTED] ] ::.
 Systems  Network Administrator :: Programmer
 [ phone - 208.343.3110 ][ pager - 208.387.9983 ]
 
 
 -- 
 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] easy question.

2001-01-24 Thread Chris Hayes

proposed IF:
 if(($fname)  ($lname)  ($email))

Alex:
 if (isset($fname)  isset($lname)  isset($email)) {
 echo "test";
 I believe the parens in your code don't do anything. anyway, best o' my
 knowledge that's the way to do it.

First IF tests whether the vars are 'true', Alex's IF tests whether they 
exist.

Chris



--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

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