php-general Digest 19 Nov 2006 00:28:35 -0000 Issue 4467

Topics (messages 244832 through 244841):

regular expressions
        244832 by: Børge Holen

How to check value in multidimensional array
        244833 by: Erik Gyepes
        244835 by: Erik Gyepes
        244836 by: Oliver Block

PHP Programmers
        244834 by: benc11.gmail.com
        244837 by: Dave Goodchild
        244838 by: tedd
        244839 by: Larry Garfield

How to work with virtual (seo) URLs?
        244840 by: Erik Gyepes
        244841 by: testkonto

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Ok I seem to need to learn regular expressions more than anything.

this is what im working on:

["desc"] = " <c> FFFFFF topic <c> 999999 rest of the text ",

$string = preg_replace("/<c>\s\w[0-9A-F]+/","",$string);

prints out:     topic  rest of the text     ( with double spaces :(, I thought 
\s would fix that )

however how would I go on this:
 
<font color="colorcode">topic</font>
<font color="colorcode">rest of thetext</font>

Almost anything I do with the above statement either throws me off with a 
modifier error or prints out what it should not


---
Børge
Kennel Arivene 
http://www.arivene.net
---

--- End Message ---
--- Begin Message ---
Hi guys,

I have an array with navigation items like that:

$navigationItemArr = array("Home"=>"home",
                 "Profile"=>"profile",
                 "Photogallery"=>"photogallery",
                 "Contact"=>array("contact","subsection")
                 );

How can I check for a value in this array?
I tried something like this:


.
.
..for.... $i++.. { // there is a normal for cycle, this is just an illustration
.
.

       if(in_array($bodyVariablePiece[$i], $navigationItemArr)) {
           echo "$bodyVariablePiece[$i] [$i] - ok<br />";
       }
       else {
           echo "$bodyVariablePiece[$i] [$i] - error<br />";
       }
.
.
}
.
.


* in $bodyVariablePiece are values extracted from URL like - home, profile, photogallery, contact Everything works except contact - there it show error. So what is the correct way to check values in multidimensional arrays? Is it possible with in_array() function?

Thanks,
Erik

--- End Message ---
--- Begin Message ---
Oliver Block wrote:
Am Samstag, 18. November 2006 19:46 schrieb Erik Gyepes:
What exactly do you need to do? You should read the manual too, at
I would like to check if the value is really in the array, if it is not then I would like do some other things. (so not check if it is an array or not, as in your example) But my iteration not worked in multidimensional arrays.
--- End Message ---
--- Begin Message ---
Am Samstag, 18. November 2006 22:08 schrieb Erik Gyepes:
> Oliver Block wrote:
> > Am Samstag, 18. November 2006 19:46 schrieb Erik Gyepes:
> >
> > What exactly do you need to do? You should read the manual too, at
>
> I would like to check if the value is really in the array, if it is not
> then I would like do some other things. (so not check if it is an array
> or not, as in your example) But my iteration not worked in
> multidimensional arrays.

>>$navigationItemArr = array("Home"=>"home",
>>                  "Profile"=>"profile",
>>                  "Photogallery"=>"photogallery",
>>                  "Contact"=>array("contact","subsection")
>>                  );

foreach($navigationItemArr as $k => $v) {
   if(is_array($v) {
      /* $v is array */
      foreach($v as $kk => $vv) {
          /* $kk hold the keys, $vv the associated values */
      }
  } else {
      /* $v is no array*/
  }
}

If you have to handle deeper nesting, i.e. $vv can hold arrays too, you should 
use a recursion. If only $v can hold an array and not $vv the above should 
work.

Regards,

Oliver


-- 
Leben ist mehr als ... 
<http://www.nak-nrw.de/index.php?id=71>

--- End Message ---
--- Begin Message ---
Does anyone know of a good website, which rates PHP programmers?  or Does
anyone know of a good, trustworthy, reliable, and reasonably price
programmer(s)?

--- End Message ---
--- Begin Message ---
I charge £20(approx $40) per hour or by the job, code in php, use mysql, and
produce front end in xhtml/css. Recent example:
dontjustsitthere.co.uk/stage/.

On 11/18/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Does anyone know of a good website, which rates PHP programmers?  or Does
anyone know of a good, trustworthy, reliable, and reasonably price
programmer(s)?




--
http://www.web-buddha.co.uk

--- End Message ---
--- Begin Message ---
At 1:03 PM -0800 11/18/06, [EMAIL PROTECTED] wrote:
Does anyone know of a good website, which rates PHP programmers?  or Does
anyone know of a good, trustworthy, reliable, and reasonably price
programmer(s)?

Nope, we're all a bunch of over-priced goof-offs. :-)

But seriously, if you want to post your problem here and ask for people to help, this is the place.

Give us a general outline of what you want and those interested can contact you off-list.

Sounds fair, doesn't it gang?

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Saturday 18 November 2006 15:03, [EMAIL PROTECTED] wrote:
> Does anyone know of a good website, which rates PHP programmers?  or Does
> anyone know of a good, trustworthy, reliable, and reasonably price
> programmer(s)?

For what definition of reasonably priced? :-)  My company has done sites 
ranging from small non-profits up through multiple tier-one universities.  
We're based in the Chicago area.  Contact me off list for details if you're 
interested in more info.

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
Hi folks,
my another question is how to work with URLs like below in PHP:

http://www.example.com/section/
http://www.example.com/section/subsection/
http://www.example.com/section/subsection/subsubsection/
http://www.example.com/section/subsection/subsubsection/ ....

These URLs works very well with this mod_rewrite rules:

----
RewriteEngine On

#check if file or directory real exists:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#do the rule only if the address has no extension:
RewriteCond %{REQUEST_URI} !\.[[:alnum:]]+$
#replace /whatever to /whatever/, not apply to whatever/!
RewriteRule ^(.+[^/])$ /$1/ [R]

#do the rule only if the address ends with trailing slash:
RewriteCond %{REQUEST_URI} ^.*/$
#if the rule ends with trailing slash then redirect to index.php..
RewriteRule ^(.*)/$ /index.php?p=$1 [L]
----

So Apache stage is solved, but how about the PHP stage?
The problem is that there can be many of subsections and how I can know that for example /animals/ is a subsection of /photogallery/ and not /profile/ ???

[url]http://www.example.com/photogallery/animals/[/url] - GOOD
[url]http://www.example.com/profile/animals/[/url] - BAD

How do you solve these things?

One idea which I had is to store sections in array an then compare them with the section's name in URL, but I can't get it work for more nested URL's.

Any ideas or web resources are appreciated!
Cheers.

--- End Message ---
--- Begin Message ---
You did not describe the problem.

Every script file has a location within the servers hierarchy. If you want to 
know in which script your code is executed, you can query the variable

$_SERVER['SCRIPT_URI'];

That returns the URI of the executed php-file, NOT included file. Don't you 
read manuals? :)

http://www.php.net/manual/en/language.variables.predefined.php

Regards,

Oliver

Am Sonntag, 19. November 2006 00:05 schrieb Erik Gyepes:
> Hi folks,
> my another question is how to work with URLs like below in PHP:
>
> http://www.example.com/section/
> http://www.example.com/section/subsection/
> http://www.example.com/section/subsection/subsubsection/
> http://www.example.com/section/subsection/subsubsection/ ....
>
> These URLs works very well with this mod_rewrite rules:
>
> ----
> RewriteEngine On
>
> #check if file or directory real exists:
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
>
> #do the rule only if the address has no extension:
> RewriteCond %{REQUEST_URI} !\.[[:alnum:]]+$
> #replace /whatever to /whatever/, not apply to whatever/!
> RewriteRule ^(.+[^/])$ /$1/ [R]
>
> #do the rule only if the address ends with trailing slash:
> RewriteCond %{REQUEST_URI} ^.*/$
> #if the rule ends with trailing slash then redirect to index.php..
> RewriteRule ^(.*)/$ /index.php?p=$1 [L]
> ----
>
> So Apache stage is solved, but how about the PHP stage?
> The problem is that there can be many of subsections and how I can know
> that for example /animals/ is a subsection of /photogallery/ and not
> /profile/ ???
>
> [url]http://www.example.com/photogallery/animals/[/url] - GOOD
> [url]http://www.example.com/profile/animals/[/url] - BAD
>
> How do you solve these things?
>
> One idea which I had is to store sections in array an then compare them
> with the section's name in URL, but I can't get it work for more nested
> URL's.
>
> Any ideas or web resources are appreciated!
> Cheers.

--- End Message ---

Reply via email to