stoppen na 10 letters

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Senior, Medior and Junior SAP HANA Developer

Vacature details Vakgebied: Software/IT Opleiding: Medior Werklocatie: Veldhoven Vacature ID: 12696 Introductie Our client is the world's leading provider of lithography systems for the semiconductor industry, manufacturing complex machines that are critical to the production of integrated circuits or chips. Our purpose is “unlocking the potential of people and society by pushing technology to new limits”. We do this guided by the principles “Challenge”, “Collaborate” and “Care”. Wat verwachten we van jou? SAP Certified Application Associate - SAP HANA Cloud Modeling (training and/or certification) Bachelor degree or higher Excellent understanding of SAP HANA (2.0 / Cloud), Data Modelling and writing

Bekijk vacature »

Nvt nvt

nvt nvt

25/12/2007 20:48:00
Quote Anchor link
hallo

ik zoek een script voor bijv na 10 letters ... te zetten in plaats van verderte tekst te laten zien,
zoals hierlinks bij laatste forum berichten gedaan word.
dus ipv "hallo dit is een tekst die te groot is" maakt hij dan "hallo dit is een...".

alvast bedankt
 
PHP hulp

PHP hulp

03/05/2024 21:41:55
 
PHP Newbie

PHP Newbie

25/12/2007 20:51:00
Quote Anchor link
substr($string,0,10);

En een functie:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
function afkorten($string, $aantal)
{

    if(strlen($string) < $aantal)
    {

        return $string;
    }

    else
    {
        return substr($string, 0, 10).'...';
    }
}


echo afkorten('een tekst langer dan 10 tekens', 10);
?>
Gewijzigd op 01/01/1970 01:00:00 door PHP Newbie
 
- SanThe -

- SanThe -

25/12/2007 20:51:00
 
Nvt nvt

nvt nvt

25/12/2007 20:52:00
Quote Anchor link
dankje, dat was snel:)
 
Martijn B

Martijn B

25/12/2007 21:33:00
Quote Anchor link
Dit:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
<?php
if(strlen($string) < $aantal)
{

  return $string;
}

else
{
  return substr($string, 0, 10).'...';
}

?>


Zoe je kunnen vervangen door:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
<?php
if( isset($string[$aantal]) )
{

   return substr($string, 0, 10).'...';
}

return $string;
?>



Deze code is wat sneller.
Gewijzigd op 01/01/1970 01:00:00 door Martijn B
 
PHP Newbie

PHP Newbie

25/12/2007 21:53:00
Quote Anchor link
Je hebt gelijk martijn, maar waar praten we over:

Gemiddelde parse tijd script 1: 0.00100000000103822240 microseconde
Gemiddelde parse tijd script 2: 0.00100000000021200597 microseconde
Verschil: 0.00000000000082621648 microseconde
Verschil 0.00000008262163930794%
Gewijzigd op 01/01/1970 01:00:00 door PHP Newbie
 
Joren de Wit

Joren de Wit

25/12/2007 22:01:00
Quote Anchor link
@Martijn: om precies te zijn, zou het dan
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?php
$string
[$aantal-1]
?>

moeten zijn. De key met waarde 10 is immers de 11e key uit de array/string.
 
Martijn B

Martijn B

25/12/2007 22:15:00
Quote Anchor link
@PHP Newbie:

Ik geef gewoon een andere manier op dit probleem op te lossen.

Test ook eens met een lap tekst...
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.