metroid2 Posted November 3, 2012 Report Share Posted November 3, 2012 Sveicināti, jautājums ir tāds.. Kādu funcīju izmantot lai noņemtu nevēlamos simbolus no teksta kas nāk no datubāzes.. Lai būtu lielāka skaidrība lūk koda daļā: if ($data['photo_title']){ echo "".$data['photo_title'].""; } else { echo "".$data['photo_filename'].""; } Tākā, ja nav informācīja photo_title, tad izvada photo_filename. Bet piemēram man ir bilde: divains-cilvēks.jpg :D Kādu funciju var izmantot lai no divains-cilvēks.jpg izvestu divains cilvēks. Quote Link to comment Share on other sites More sharing options...
briedis Posted November 3, 2012 Report Share Posted November 3, 2012 Būtu gan jānodefinē, kas ir "nevēlami" simboli... Vari izmantot kaut vai str_replace().. Quote Link to comment Share on other sites More sharing options...
metroid2 Posted November 3, 2012 Author Report Share Posted November 3, 2012 principā nevēlamie simboli: - _ un faila tips - .jpg, .gif u.t.t.. Quote Link to comment Share on other sites More sharing options...
briedis Posted November 3, 2012 Report Share Posted November 3, 2012 nu tad izmantojot str_replace aizstāj šos simbolus ar tukšumu... Quote Link to comment Share on other sites More sharing options...
metroid2 Posted November 3, 2012 Author Report Share Posted November 3, 2012 (edited) $find = array("-",".jpg"); $replace = array("\n"); echo (str_replace($find,$replace,$data['photo_filename'])); Paldies. Edited November 3, 2012 by metroid2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.