Jump to content

[SOLVED] If begins with..


wwfc_barmy_army

Recommended Posts

$string = substr($text, 0, 5);

if ($string == "start") {echo "contains the start string!"}

else {echo "doesnt contain the start string!"}

 

I think this is what you want, btw, change 5 to the number of strings of the start word, like "start" has 5 characters.

Ted

Link to comment
https://forums.phpfreaks.com/topic/36941-solved-if-begins-with/#findComment-176261
Share on other sites

Can you just confirm where the field would go in there, and where the text i am looking for would go in there? is it;

 

$string - where it gets the field

 

$start - the text i want to search for in the field

 

And what does the '=== 0' do?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/36941-solved-if-begins-with/#findComment-176269
Share on other sites

1 last question, how would i be able to say if it starts with this or this?

 

What i have so far is:

<?php
if(strpos($qry[link], "http://") === 0)
echo "Starts!";
else
echo "Doesn't!";
?>

 

But if i try putting the or operator (||) after it always says 'doesnt'.

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/36941-solved-if-begins-with/#findComment-176278
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.