note 77398 added to function.strpos
| From: | Cybertinus at osu1 dot php dot net | Date: | Tue, 28 Aug 2007 11:05:20 +0000 |
| Subject: | note 77398 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129848@lists.php.net to get a copy of this message | ||
@Wagner Christian:
Yes, there are better methods. The best is to just cast is. You cast like this:
<?php
$id = 1;
$string = (string) $id;
?>
If you var_dump() $string now you get the following output:
string(1) "1"
This is the recommended method. You're example should look like this then:
<?php
$id = 1;
$my_text = "hel124lo";
$first_position =strpos($my_text , (string) $id);
?>
----
Server IP: 83.137.20.107
Probable Submitter: 86.86.160.207
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- https://master.php.net/note/edit/77398
Del: integrated -- https://master.php.net/note/delete/77398/integrated
Del: useless -- https://master.php.net/note/delete/77398/useless
Del: bad code -- https://master.php.net/note/delete/77398/bad+code
Del: spam -- https://master.php.net/note/delete/77398/spam
Del: non-english -- https://master.php.net/note/delete/77398/non-english
Del: in docs -- https://master.php.net/note/delete/77398/in+docs
Del: other reasons-- https://master.php.net/note/delete/77398
Reject -- https://master.php.net/note/reject/77398
Search -- https://master.php.net/manage/user-notes.php