You could extract just that section of the sting (the bit without '&limitsize=' in).
Like so:
$var = substr($var, 0, strlen($var) - strlen("&limitsize="));
Try that, I haven't, lol.
You could extract just that section of the sting (the bit without '&limitsize=' in).
Like so:
$var = substr($var, 0, strlen($var) - strlen("&limitsize="));
Try that, I haven't, lol.
NogDog wrote:I copied and pasted your code, and it worked fine. Perhaps you are outputting the $sprint_user_photo_link variable instead of the $image_url that you save the replaced text in?
Maybe it's different php code level. I think I have the displays right because I did everything but the '&' and get this output:
Sprint user photo link after cleanup: http://pictures.sprintpcs.com//mmps/RECIPIENT/001_26xxx848d2ff0ca3_1/2.2?inviteToken=NEqrxxx5m8awcUcLo7qL& .
I'll keep trying.
What's happens if you only replace the "&" character ?
If you are bothered, my code worked perfectly.
$sprint_user_photo_link = 'http://pictures.sprintpcs.com//mmps/RECIPIENT/001_xxxxb848d2ff0ca3_1/2.2?inviteToken=NEqrxxJ5m8awcUcLo7qL&limitsize= ';
$image_url = $var = substr(trim($sprint_user_photo_link), 0, strlen($sprint_user_photo_link) - strlen("&limitsize="));
echo $image_url;
// http://pictures.sprintpcs.com//mmps/RECIPIENT/001_xxxxb848d2ff0ca3_1/2.2?inviteToken=NEqrxxJ5m8awcUcLo7qL
suntra wrote:What's happens if you only replace the "&" character ?
code here:
$image_url = str_replace('limitsize=', '', $sprint_user_photo_link);
echo nl2br(". \n Sprint user photo link after cleanup: $image_url ");
$image_url = str_replace('&', '', $image_url);
// put in here <--- replace this, with this, in here
echo nl2br(". \n Sprint user photo link after cleanup #2 for '&': $image_url .");
Output below: --------------------------------------------------------------------
this is snatch Sprint photo link . Sprint photo link is (before clean) http://pictures.sprintpcs.com//mmps/RECIPIENT/001_266db848d2ff0ca3_1/2.2?inviteToken=NEqrJUJ5m8awcUcLo7qL&limitsize= .
..
Sprint user photo link after cleanup: http://pictures.sprintpcs.com//mmps/RECIPIENT/001_266db848d2ff0ca3_1/2.2?inviteToken=NEqrJUJ5m8awcUcLo7qL& .
Sprint user photo link after cleanup #2 for '&': http://pictures.sprintpcs.com//mmps/RECIPIENT/001_266db848d2ff0ca3_1/2.2?inviteToken=NEqrJUJ5m8awcUcLo7qLamp; .
Like i said, mine works fine.
Why mess around when you have something that works?
rowanparker wrote:Like i said, mine works fine.
Why mess around when you have something that works?
Rowan, Thanks but
It didn't work for me. Unless there's some other mistake I'm missing.
$image_url = $var = substr(trim($sprint_user_photo_link), 0, strlen($sprint_user_photo_link) - strlen("&limitsize="));
echo nl2br(". \n Sprint user photo link after cleanup: $image_url ");
output:
Sprint user photo link after cleanup: http://pictures.sprintpcs.com//mmps/RECIPIENT/001_266db848d2ff0ca3_1/2.2?inviteToken=NEqrJUJ5m8awcUcLo7qL&
This is approaching 'bug' territory. It found it and replaced it but ignored the '&'.
In some doc I'm seeing (and it also show in my reply before this one) that '&' is sometimes represented by '&'.
Still researching.
Try:
$image_url = $var = substr(trim($sprint_user_photo_link), 0, strlen($sprint_user_photo_link) - strlen("&limitsize=") + 1);
echo nl2br(". \n Sprint user photo link after cleanup: $image_url ");[
Should work, unless it just does not like your, lol.
kansaschuck wrote:...
In some doc I'm seeing (and it also show in my reply before this one) that '&' is sometimes represented by '&'.Still researching.
Are you doing a "view source" in your browser to see what is really there, as opposed to just what the browser itself is showing?
If it might be "&", you could handle either/or with either of these:
$image_url = str_replace(array('&limitsize=', '&limitsize=', '', $sprint_user_photo_link);
// ...or...
$image_url = preg_replace('/&(amp;)?limitsize=/', '', $sprint_user_photo_link);
rowanparker wrote:Like i said, mine works fine.
Why mess around when you have something that works?
this worked for me.
$image_url = str_replace('&limitsize=', '', $sprint_user_photo_link);
whacha think?
If it works, keep it!