Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 15
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
Przyznam, że jestem pod sporym wrażeniem. Od wielu lat zajmuje się grafiką przeznaczoną do druku ze szczególnym uwzględnieniem opakowań. Z radością stwierdzam, iż twórca serwisu jest moim ulubionym typem potencjalnego współpracownika (choć branża troszeczkę inna) tzn. pada pytanie i błyskawicznie pada konkretna odpowiedź bez względu na stopień skomplikowania pytania. Gorąco polecam współpracę, gdyż macie pewność że nie zostaniecie potraktowani sloganami typu "oczywiście", "nie ma sprawy" tylko otrzymacie konkretną pomoc. Tak trzymać! Na pewno jeszcze nie raz skorzystam

Paweł
Studio Gama

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

strstr

(PHP 3, PHP 4, PHP 5)

strstr -- Find first occurrence of a string

Description

string strstr ( string haystack, string needle )

Returns part of haystack string from the first occurrence of needle to the end of haystack.

If needle is not found, returns FALSE.

If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.

Notatka: This function is case-sensitive. For case-insensitive searches, use stristr().

Przykład 1. strstr() example

<?php
$email
= 'user@example.com';
$domain = strstr($email, '@');
echo
$domain; // prints @example.com
?>

Notatka: If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.

strstr() has been binary safe since PHP 4.3.0

See also ereg(), preg_match(), stristr(), strpos(), strrchr(), and substr().




User Contributed Notes

onuryerlikaya at hotmail dot com
25-Jan-2006 09:00

<?php
$piece   
= 6;
$data    = 'djhfoldafg9d7yfr3nhlrfkhasdfgd';
$piece1    = substr($data,0,$piece);
$piece2    = strstr($data,substr($data,$piece,$piece));
echo
'$piece1 :'.$piece1; // $piece1 :djhfol
echo "<br>";
echo
'$piece2 :'.$piece2; // piece2 :dafg9d7yfr3nhlrfkhasdfgd
?>

You can piece your string which given at $piece variable.


always_sleepz0r at removethisyahoo dot co dot uk
15-Jan-2006 08:38

//this is my little version

function rdir($d_d, $filter = null) {   
   $d = dir($d_d);while(false !== ($entry = $d->read())) {
     if ($entry!=".." && $entry!="." && $filter==null || true==stristr($entry, $filter)){ if (!is_dir($entry)) {
     $ret_arr['f'][]=$entry;}else{$ret_arr['d'][]=$entry;
   }}}$d->close();return $ret_arr;}

//usage:
$d="folder";

$dd=rdir($d);
//will return array with all files and folder names

$dd=rdir($d, "requiredneedle");
//will return array with only file/folder names containing "requiredneedle".

//$dd['f'] = files and $dd['d'] = folders
echo "<pre>";print_r($dd);echo "</pre>";


nospam AT thenerdshow.com
16-Nov-2005 01:20

It is a good practice to ensure dropdown menu submissions contain ONLY expected values:

$i=(isset($_POST['D1']))?$_POST['D1']:$o="Monday";
if (!stristr('Monday Tuesday Wednesday Thursday Friday Saturday Sunday',$i)) die();
(do database query)

This should protect against all known and unknown attacks, injection, etc.

User submitted should be cleaned through other functions.  See info under mysql_query


06-Jun-2005 06:13

suggestion for [leo dot nard at free dot fr]:
to be able to cut the string without having the html entities being cut in half, use this instead:

<?php

$oldstr
= "F&ouml;r att klippa av en str&auml;ng som inneh&aring;ller skandinaviska (eller Franska, f&ouml;r den delen) tecken, kan man g&ouml;ra s&aring;h&auml;r...";

$length = 50;

# First, first we want to decode the entities (to get them as usual chars), then cut the string at for example 50 chars, and then encoding the result of that again.

# Or, as I had it done, in one line:
$newstr = htmlentities(substr(html_entity_decode($oldstr), 0, $length));
$newstr2 = substr($oldstr, 0, $length);
# It's not quite as much code as the snippet you've coded to remove the half-portions... ;)
# Hopefully somebody finds this useful!
echo "Without the decode-encode snippet:
$newstr2

With the decode-encode snippet:
$newstr"
;
?>

The above outputs this:

Without the decode-encode snippet:
F&ouml;r att klippa av en str&auml;ng som inneh&ar

With the decode-encode snippet:
F&ouml;r att klippa av en str&auml;ng som inneh&aring;ller skandin

First post in this db ;)
Best regards, Mikael R

 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt