Re: [PHP] Strange string stuff -- maybe everything is ending...

2012-12-22 Thread Stefan Wixfort

On 22.12.2012 00:31, Bastien wrote:


On 2012-12-21, at 5:05 PM, Ken Robinson kenrb...@rbnsn.com wrote:


A much easier way to do this would be to use a temporary array and then explode:

$tmp = array();
while($row = mysql_fetch_array($result)) // pulling stuff from a 
database
{
$tmp[] = $row['category'];
}

$topic = explode('~',$tmp); // put the delimiter between each entry
echo($topic);   // this result is used in an AJAX script




Shouldn't that be implode to convert the array to string with the delimiter?


Bastien



Yes, it should be implode().

Stefan

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



Re: [PHP] Friday - Return of Brain Teasers

2012-10-06 Thread Stefan Wixfort

On 06.10.2012 03:08, Tamara Temple wrote:

On Fri, 2012-10-05 at 22:50 +0200, iostream wrote:

If you want to execute some code...

I'm sure you've all heard of the new goes to operator by now, but I
hope it might be new to somebody.

$i = 10;
while ($i -- 0) { // while $i goes to 0
  echo $i .\n;
}


Okay, I haven't heard of it, and I don't get it. AFAIK, this operator
does not exist, but I don't get the trick that's being applied.




while ($i--  0)

should clearify things

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



Re: [PHP] Need help to understand a code

2012-09-22 Thread Stefan Wixfort

On 22.09.2012 12:34, Ashickur Rahman Noor wrote:

Hi all

I need some help to understand a code. The code is like this

$result = mysql_query($sSQL) or die(err:  . mysql_error().$sSQL);

 if($row = mysql_fetch_array($result))
 {
   foreach($row as $key =$value){ $$key=$value;}
 }



I don't get the code from the foreach loop.


I assume that you mean the meaning of $$key = $value.
This is a variable variable[1]
This means if you have a key in your array named dino then you assign 
$dino the value of $value for the current row.


so: $key = 'dino', $value = 'saur'
= $$key = $value = $$key = 'saur' = $dino = 'saur'

Hope this was somewhat helpful and understandable.

[1] http://php.net/manual/en/language.variables.variable.php


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



Re: [PHP] What's happened to our newsgroup?

2012-06-26 Thread Stefan Wixfort

On 26.06.2012 23:48, Simon J Welsh wrote:


On 27/06/2012, at 9:45 AM, Daniel Brown wrote:


On Tue, Jun 26, 2012 at 5:42 PM, Matijn Woudt tijn...@gmail.com wrote:


Isn't everyday friday in summer? ;)


If it is, then it could be argued that every day is a Monday in
winter --- and right now, those poor folks in the southern hemisphere
(I'm looking at you, Thiago Pojda) are in a season of endless Mondays.

--
/Daniel P. Brown



So glad I take Mondays off then.


Clever gi... er guy...



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



RE: [PHP] Parse domain from URL

2007-06-06 Thread Stefan Wixfort

 From: Brad Fuller [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 06, 2007 5:44 PM
 Subject: [PHP] Parse domain from URL
 
 Hey guys,
 
 I'm faced with an interesting problem, and wondering if there's an easy
 solution.
 
 I need to strip out a domain name from a URL, and ignore subdomains (like
 www)
 
 I can use parse_url to get the hostname. And my first thought was to take
 the last 2 segments of the hostname to get the domain.  So if the URL is
 http://www.example.com/
 Then the domain is example.com.   If the URL is http://example.org/ then
 the domain is example.org.
 
 This seemed to work perfectly until I come across a URL like
 http://www.example.co.uk/
 My script thinks the domain is co.uk.
 
 So I added a bit of code to account for this, basically if the 2nd to last
 segment of the hostname is co then take the last 3 segments.
 
 Then I stumbled across a URL like http://www.example.com.au/
 
 So it occurred to me that this is not the best solution, unless I have a
 definitive list of all exceptions to go off of.
 
 Does anyone have any suggestions?
 
 Any advice is much appreciated.
 
 Thanks,
 Brad
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

Maybe use some regexp like this:
$url = http://www.a-domain.co.uk;

$domain = preg_match( !^(http://)([-a-z0-9]+(?:\.[-a-z0-9]+)*)$!i ); //
you will get www.a-domain.co.uk // So u can search for www. In front of
the string to replace it or // you could edit the search for ignoring the
'www.'

Echo $domain[2];


Greetings,

Stefan

Note: this is untested.

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