---
title: "Längd på sträng och på"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/104448-längd-på-sträng-och-på"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "nitro2k01"
published: "2004-05-27T14:35:36.000Z"
updated: "2004-05-27T14:38:51.000Z"
replies: 2
views: 289
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/104448-längd-på-sträng-och-på"
---

# Längd på sträng och på

## #1 — nitro2k01, 2004-05-27T14:35Z

En snabb sökning gav inget, så jag ställer frågan:
Hur får man fram längden på en sträng samt på en array? (Vill veta båda, om de inte ser likadana ut.)

Permalänk: https://www.webforum.nu/p/104448

## #2 — nitro2k01, 2004-05-27T14:37Z

Kom på själv hur man gör för strängar:

```
$lengd = strlen($strang);
```

 
Men hur gör man för arrayer?

Permalänk: https://www.webforum.nu/p/1354722

## #3 — Qimen, 2004-05-27T14:38Z

Med count för arrayer <http://se.php.net/manual/sv/function.count.php> :)

```php
<?php
$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
$result = count($a);
// $result == 3

$b[0]  = 7;
$b[5]  = 9;
$b[10] = 11;
$result = count($b);
// $result == 3;
?>
```

Permalänk: https://www.webforum.nu/p/1354723

---

Tråden på webben: https://www.webforum.nu/amne/php/104448-längd-på-sträng-och-på
